I have integrated flutter localizations dependent of system language, works very well. But I want to "force" language programmatically, without matters on system language.
My app root:
return GetMaterialApp(
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: const [
Locale('sr', ''),
Locale('en', ''),
],
My lang config file:
arb-dir: lib/l10n
template-arb-file: app_sr.arb
output-localization-file: app_localizations.dart
Any every next new entering into the app will "keep" the user choose preferred language. Thank you!
You can add the locale attribute to your MaterialApp, like that:
If you need change in another part of your app, you can change de Locale in your AppLocalizations class.