Generated by the Very Good CLI 🤖
A Very Good Project created by Very Good CLI.
This project contains 3 flavors:
- development
- staging
- production
To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:
# Development
$ flutter run --flavor development --target lib/main_development.dart
# Staging
$ flutter run --flavor staging --target lib/main_staging.dart
# Production
$ flutter run --flavor production --target lib/main_production.dart*Refresher works on iOS, Android, Web, and Windows.
To run all unit and widget tests use the following command:
$ flutter test --coverage --test-randomize-ordering-seed randomTo view the generated coverage report you can use lcov.
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.htmlThis project relies on flutter_localizations and follows the official internationalization guide for Flutter.
- To add a new localizable string, open the
app_en.arbfile atlib/l10n/arb/app_en.arb.
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
- Then add a new key/value and description
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- Use the new string
import 'package:refresher/l10n/l10n.dart';
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return Text(l10n.helloWorld);
}Update the CFBundleLocalizations array in the Info.plist at ios/Runner/Info.plist to include the new locale.
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...- For each supported locale, add a new ARB file in
lib/l10n/arb.
├── l10n
│ ├── arb
│ │ ├── app_en.arb
│ │ └── app_es.arb
- Add the translated strings to each
.arbfile:
app_en.arb
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
app_es.arb
{
"@@locale": "es",
"counterAppBarTitle": "Contador",
"@counterAppBarTitle": {
"description": "Texto mostrado en la AppBar de la página del contador"
}
}
To use the latest translations changes, you will need to generate them:
- Generate localizations for the current project:
flutter gen-l10n --arb-dir="lib/l10n/arb"Alternatively, run flutter run and code generation will take place automatically.
Meetup Wednesday Today’s Scope
- Token Security
Knowing Flutter !== Knowing Mobile Development
Extras
- HTTP Certificate Pinning
1: Set the token to expire after a set time so that a log-in is forced Useful for:
- Where tight security isn’t required
- Users de-activated elsewhere so when they are de-activated, they shouldn’t be able to access the app since the token is long living (Example: User deactivated on Google Admin, so their login won’t work, but they may have a valid token from the backend where the backend prefers to issue long-lasting tokens)
Steps
- Log in
- Go on the landing page
- Open the debrief page
2: Refresh token Useful for:
-
Access Token
-
Refresh
-
More security-conscious APIs where instead of a user being forced to log back in to maintain the experience, they get two tokens, access token and a refresh token.
-
The access token is the token used to make the calls, then when it expires in the middle of a transaction to the target API, it’s refreshed and the request retried so that it doesn’t break the user flow
-
Call login endpoint (Username & Password)
-
Receive Access Token (To call the APIs) & Receive the Refresh Token (Longer lifespan)
-
Call your APIs normally,
-
At some point, the token expires (5 minutes, 10 minutes, 15 minutes, 1 request -> Token expired, refresh, then make next request)
-
At this point, you use your refresh token, to call an endpoint that will give you a new access token
-
Use the new token to make the request
Steps: (feature/setup-refresh-token)
- Disable hive is logged out: lib/services/hive_service.dart
- Enable error interceptor: lib/utils/network.dart
- Enable dummy token expiration: lib/services/debrief_service.dart NB: Won’t need the error handlers for 401 in the individual methods
3: Auto log out Useful for:
- Banks apps where you need to have the device request you to get signed out first
- So banks are security sensitive
- Slightly tedious to set-up, was unable to cover this in the sample app on time
Process
- Wrap the app with Overlay (Portal)
- Have a ticker to manage the time
- When the time expires, use the overlay portal to show the prompt
- Use Flutter to force an app restart, once it fails the check, then you have to log in again manually