π€ Generated via Riverpod Core Brick
Testing Isar
Before anything, run:
flutter pub get
This project exploits code generation extensively.
Before anything, you need to run build_runner
at least once before launching this application:
flutter pub run build_runner build -d
Wait until this process is done. It can even take a few minutes.
This application currently supports the following platforms: android,linux.
Since this application uses flavors, you can't just use 'flutter run`.
When you're ready to see this application in action (dev server), you can run:
# Development flavor
$ flutter run --flavor development --target lib/main_development.dart
# Staging flavor
$ flutter run --flavor staging --target lib/main_staging.dart
# Production flavor
$ flutter run --flavor production --target lib/main_production.dart
And look at this software go!
Building an application can be done through flutter build
, but it's recommended to set up a CI/CD tool before releasing a staging or a production-ready executable.
A few notes about this Software.
This project contains 3 flavors:
- development
- staging
- production
This project uses well-known Clean Architecture principles, with a pinch of pragmatism.
Here's a quick recap of the libraries used in this project:
hooks_riverpod
as state management / caching / DI solutionriverpod_generator
to superchargeriverpod
freezed
to generate data classes.flutter_hooks
to easily handle ephimeral stateriverpod_lint
for a set of great riverpod-related lintsvery_good_analysis
for a set of well-known lints
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/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": "New Hello World Text"
}
}
- Use the new string
import 'package:isar_sandbox/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
.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/l10n/arb"
Alternatively, run flutter run
and code generation will take place automatically.