Closed EricKhoury closed 4 months ago
This is my setup in main Build:
Locale currentLocale = ref.watch(localeProvider).locale; .... return GestureDetector( onTap: () => FocusManager.instance.primaryFocus?.unfocus(), child: ResponsiveSizer( builder: (context, orientation, screenType) { return MaterialApp( locale: currentLocale, localizationsDelegates: [ FlutterI18nDelegate( translationLoader: FileTranslationLoader(), missingTranslationHandler: (key, locale) { log("--- Missing Key: $key, languageCode: ${locale!.languageCode}"); }, ), GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], supportedLocales: [ const Locale('en', ''), // English const Locale('sv', ''), // Swedish ], title: 'My app', theme: ThemeData( splashColor: Colors.transparent, visualDensity: VisualDensity.adaptivePlatformDensity, primarySwatch: MyTheme.CompanyColors.primary, fontFamily: 'Poppins'), navigatorKey: _navigationService.navigatorKey, onGenerateRoute: generateRoute, home: widget.child); }, )); }
Since I added the FlutterI18nDelegate inside localizationsDelegates, the whole app reloads on every file save. I get rid of the behaviour if I remove the FlutterI18nDelegate. Is there any obvious errors on my part here?
FlutterI18nDelegate
localizationsDelegates
The delegate should be created outside the widget tree, to avoid this behaviour. An example can be found here: https://github.com/ilteoood/flutter_i18n/blob/master/example/lib/network_example.dart#L20
This is my setup in main Build:
Since I added the
FlutterI18nDelegate
insidelocalizationsDelegates
, the whole app reloads on every file save. I get rid of the behaviour if I remove theFlutterI18nDelegate
. Is there any obvious errors on my part here?