demo-afgr.mp4
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
*Demo AFGR 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 random
To view the generated coverage report you can use lcov.
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.html
This project relies on flutter_localizations and follows the Package easy_localization.
-
To add a new localizable string, open the
en-US.json
file atlib/resources/langs/en-US.json
.{ "feature": { "main": { "sliverListUrl": { "dataEmpty": "Looks a bit empty here! Add your first shortened URLs." }, "title": "Recently shortend URLs" } } }
-
Then add a new key/value and description
{ "feature": { "main": { "sliverListUrl": { "dataEmpty": "Looks a bit empty here! Add your first shortened URLs." }, "title": "Recently shortend URLs" } }, "widget": { "cdsItemListTileShortcutUrl": { "iconButton": { "onPressed": { "msgSnackbar": "Link shortend {linkShortend}\nCopied to your clipboard" } } } } }
-
Use the new string
import 'package:easy_localization/easy_localization.dart'; import '../generated/locale_keys.g.dart'; @override Widget build(BuildContext context) { return Text(LocaleKeys.feature_main_title.tr()); }
or used with named arguments
import 'package:easy_localization/easy_localization.dart'; import '../generated/locale_keys.g.dart'; @override Widget build(BuildContext context) { return Text( LocaleKeys .widget_cdsItemListTileShortcutUrl_iconButton_onPressed_msgSnackbar .tr(namedArgs: {'linkShortend': 'https://short.link/123abc'}) ); }
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/resources/langs
.├── resources │ ├── langs │ │ ├── en-US.json │ │ └── es-ES.json
-
Add the translated strings to each
.json
file:es-ES.json
{ "feature": { "main": { "sliverListUrl": { "dataEmpty": "¡Parece un poco vacío aquí! Añade tus primeras URLs acortadas." }, "title": "URL acortadas recientemente" } } }
en-US.json
{ "feature": { "main": { "sliverListUrl": { "dataEmpty": "Looks a bit empty here! Add your first shortened URLs." }, "title": "Recently shortend URLs" } }, }
To use the latest translations changes, you will need to generate them:
-
Generate localizations for the current project:
dart run easy_localization:generate && dart run easy_localization:generate -f keys -o locale_keys.g.dart