fantastic app
generated by the very good cli ��
a very good project created by very good cli.
getting started ��
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
*fantastic app works on ios, android, and web.
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:fantastic_app/l10n/l10n.dart';
@override
widget build(buildcontext context) {
final l10n = context.l10n;
return text(l10n.helloworld);
}
adding supported locales
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"
}
}
Comments are closed.