-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Use case
There are multiple arguments for gen-l10n which has two syntax: --[no-]nullable-getter --[no-]synthetic-package --[no-]use-deferred-loading --[no-]required-resource-attributes.
Note: I'm going to use only nullable-getter in the examples just for simplicity.
In case of l10n.yaml configuration nullable-getter: false will be recognized however in case of gen-l10n tool the --nullable-getter false won't be recognized moreover no error is raised.
Steps:
- Create app with
arbresource file- terminal:
flutter create flutter_app && cd flutter_app && mkdir l10n && cd l10n && echo '{"test": "test"}' > app_en.arb - Windows cmd
flutter create flutter_app && cd flutter_app && mkdir l10n && cd l10n && echo {"test": "test"} > app_en.arb
- terminal:
- Add dependencies in
pubspec.yamldependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter intl: ^0.17.0
- Generate
app_localizations.dart(note: this command will create a non synthetic package soAppLocalizationscan be found underlib/l10nfolder)
flutter gen-l10n --nullable-getter false --no-synthetic-package --arb-dir l10n --output-dir lib/l10n --template-arb-file app_en.arb --output-localization-file app_localizations.dart --output-class AppLocalizations --preferred-supported-locales en - In
main.dartimportapp_localizations.dart
import 'package:flutter_app/l10n/app_localizations.dart'; - In a
buildmethod use
AppLocalizations.of(context).test;
If rerunning command via --no-nullable-getter the no nullable getter should work properly:
flutter gen-l10n --no-nullable-getter --no-synthetic-package --arb-dir l10n --output-dir lib/l10n --template-arb-file app_en.arb --output-localization-file app_localizations.dart --output-class AppLocalizations --preferred-supported-locales en
Proposal
--nullable-getter false/synthetic-package false... should just work or throw error.- If it cannot be modified, it should be properly documented when calling to
flutter gen-l10n -h