skip to Main Content

How do I programatically change Locale in Flutter when using MaterialApp.router()

I have: final themeMode = context.select<PreferencesChangeNotifier, ThemeMode>((notifier) => notifier.themeMode); final locale = context.select<LocaleChangeNotifier, Locale>((notifier) => notifier.locale); return MaterialApp.router( locale: locale, debugShowCheckedModeBanner: false, scaffoldMessengerKey: MyApp.rootScaffoldMessengerKey, localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, routeInformationParser: _routeInformationParser, routerDelegate: _routerDelegate, title: 'MyApp', theme: AppTheme.instance.lightTheme, darkTheme: AppTheme.instance.darkTheme, themeMode: themeMode,…

VIEW QUESTION

Localization delegate is messing with widget test flutter

I have a custom LocalizationDelegate that deals with my app localizations : class LocalizationDelegate extends LocalizationsDelegate<Localization> { const LocalizationDelegate(); @override bool isSupported(Locale locale) => ['en', 'fr'].contains(locale.languageCode); @override Future<Localization> load(Locale locale) async { String string = await rootBundle .loadString("assets/strings/${locale.languageCode}.json"); language =…

VIEW QUESTION

flutter_localizations error Null check operator used on a null value

I want to make MyApp with Navigation Drawer. When open drawer, I got the following exception that is occured by flutter_localization. Exception caught by widgets library ======================================================= The following _CastError was thrown building NavigationDrawer(dirty, dependencies: [_LocalizationsScope-[GlobalKey#9fbb0]]): Null check operator used…

VIEW QUESTION
Back To Top
Search