Describe the bug
My active locale resets when I close and reopen the app.
- I'm persisting my rawLocale 'fr', 'en', and 'de' using
hydrated_bloc
- The raw locale is being persisted pretty fine
- But when I close and reopen the app, the active locale resets itself and goes to fallback locale, which is 'en', Meanwhile my persisted raw locale is pretty fine
This is my app.dart
BlocBuilder<ThemeCubit, bool>(
builder: (BuildContext context, bool isDarkMode) {
return BlocBuilder<LanguageCubit, String>(
builder: (context, lang) {
return MaterialApp.router(
theme: theme.toThemeData(Brightness.light),
//theme: FlexThemeData.light(scheme: FlexScheme.hippieBlue),
darkTheme: theme.toThemeData(Brightness.dark),
themeMode: isDarkMode ? ThemeMode.dark : ThemeMode.light,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocaleUtils.supportedLocales,
locale: Locale(lang), // was TranslationProvider.of(context).flutterLocale
routerConfig: _router.config(
navigatorObservers: () => <NavigatorObserver>[
FirebaseAnalyticsObserver(
analytics: FirebaseAnalytics.instance,
),
EliteRouterObserver(),
],
),
debugShowCheckedModeBanner: false,
);
},
);
},
),
This is how I wrapped my MaterialApp widget with TranslationProvider
await runZonedGuarded(
() async => runApp(
TranslationProvider(
child: await builder(),
),
),
(error, stackTrace) => log(error.toString(), stackTrace: stackTrace),
);
To Reproduce
Steps to reproduce the behavior:
- Wrap material with
TranslationProvider
- use
TranslationProvider.of(context)flutterLocale as MaterialApp locale's attribute
- Persist your locale
- Trigger interaction that changes active locale
- The locale is changed
Expected behavior
The locale changes and updates screen, but when you close and reopen app, the locale is reset and goes to fallback locale
Describe the bug
My active locale resets when I close and reopen the app.
hydrated_blocThis is my app.dart
This is how I wrapped my MaterialApp widget with
TranslationProviderTo Reproduce
Steps to reproduce the behavior:
TranslationProviderTranslationProvider.of(context)flutterLocaleas MaterialApp locale's attributeExpected behavior
The locale changes and updates screen, but when you close and reopen app, the locale is reset and goes to fallback locale