flutter boilerplate
a boilerplate project for flutter using riverpod, dio, auto_route, freezed and generated with very_good_cli.
this is a very simple boilerplate application, this has following features.
- user can sign in and up
- after signing in he can see a list of items
it uses a mock json server which doesn’t store or validate anything, so for signing in/up any email, password will simply work.
riverpod was used for state management, but there’s an old implementation with flutter bloc as well, you may check out bloc branch, though that branch doesn’t have many of the latest changes.
getting started ��
you can go through this flutter starter pack.
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 boilerplate works on ios, android, and web.
use makefile / derry to avoid writing your own scripts.
you can run all these scripts manually or could use makefile / derry and maintain a file, where you can define all those scripts and run in a very convinient way. all the scripts for this project is defined here derry scripts and makefile scripts
example:
run make watch
or derry watch
instead of
flutter pub run build_runner watch --delete-conflicting-outputs
or run make build_apk_dev
or derry build_apk_dev
instead of
flutter build apk --flavor development -t lib/main_development.dart
running tests ��
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
working with translations ��
this project relies on flutter_localizations and follows the official internationalization guide for flutter.
adding strings
- 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": "hello world text"
}
}
- use the new string
import 'package:flutter_boilerplate/l10n/l10n.dart';
@override
widget build(buildcontext context) {
final l10n = context.l10n;
return text(l10n.helloworld);
}
adding supported locales
if you face trouble after with translations, then run
flutter gen-l10n --template-arb-file=arb/app_en.arb
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>
...
adding translations
- 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"
}
}
same implementation in other platforms
todo
- updating it on daily basis as much as possible, work in progess[wip].
found this project useful ❤️
- support by clicking the ⭐ button on the upper right of this page. ✌️
Comments are closed.