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
*Flutter Riverpod Firebase works on iOS, Android, Web, and Windows.
The project is structured as follows:
βββ lib
β βββ src
β β βββ app
β β β βββ app.dart
β β βββ configs
β β β βββ server.dart
β β βββ data
β β β βββ datasources
β β β β βββ remote
β β β β β βββ auth_data_remote.dart
β β β β β βββ user_data_remote.dart
β β β β βββ local
β β β β β βββ auth_data_local.dart
β β β β β βββ todo_data_local.dart
β β β β β βββ user_data_local.dart
β β β βββ entites
β β β β βββ todo.dart
β β β βββ repositories
β β β β βββ auth_repository.dart
β β β β βββ auth_repository_impl.dart
β β βββ di
β β β βββ modules
β β β β βββ auth_module.dart
β β β β βββ routes_module.dart
β β β β βββ storage_module.dart
β β β βββ injection.config.dart
β β β βββ injection.dart
β β βββ features
β β β βββ auth
β β β β βββ view
β β β β β βββ login_form.dart
β β β β β βββ login_page.dart
β β β β βββ view_model
β β β β β βββ auth_riverpod.dart
β β β β βββ auth.dart
β β β βββ todo
β β β β βββ view
β β β β β βββ todo_page.dart
β β β β βββ view_model
β β β β β βββ todo_riverpod.dart
β β β β βββ todo.dart
β β β βββ feature.dart
β β βββ l10n
β β β βββ arb
β β β β βββ app_en.arb
β β β β βββ app_ja.arb
β β β βββ l10n.dart
β β β βββ l10n_model.dart
β β βββ routes
β β β βββ app_router.dart
β β β βββ guards.dart
β β βββ shared
β β β βββ extensions
β β β βββ listeners
β β β βββ resources
β β β βββ storage
β β β βββ theme
β β β βββ widgets
β β β βββ utils
β βββ firebase_options.dart
β βββ main.dart
β βββ main_development.dart
β βββ main_staging.dart
β βββ main_production.dart
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 official internationalization guide for Flutter.
- To add a new localizable string, open the
app_en.arb
file atlib/src/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:flutter_riverpod_firebase/l10n/src/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/src/l10n/arb
.
βββ l10n
β βββ arb
β β βββ app_en.arb
β β βββ app_es.arb
- Add the translated strings to each
.arb
file:
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/src/l10n/arb"
Alternatively, run flutter run
and code generation will take place automatically.