File tree 1 file changed +20
-5
lines changed
1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,24 @@ class MyApp extends StatelessWidget {
159
159
}
160
160
}
161
161
162
+ Locale _getLocale () {
163
+ Box box = Hive .box (prefBox);
164
+ var languagePref = box.get (prefLanguageKey);
165
+ Locale locale = const Locale (
166
+ 'en' ,
167
+ 'US' ,
168
+ );
169
+ if (languagePref != null ) {
170
+ List localeString = languagePref.split ('_' );
171
+ if (localeString.length == 2 ) {
172
+ locale = Locale (localeString[0 ], localeString[1 ]);
173
+ } else if (localeString.length == 1 ) {
174
+ locale = Locale (localeString[0 ], '' );
175
+ }
176
+ }
177
+ return locale;
178
+ }
179
+
162
180
@override
163
181
Widget build (BuildContext context) {
164
182
return GetMaterialApp (
@@ -173,13 +191,10 @@ class MyApp extends StatelessWidget {
173
191
unknownRoute: AppPages .unknownRoute,
174
192
defaultTransition: kIsWeb ? Transition .topLevel : Transition .native ,
175
193
translations: LocaleString (), // Translations
176
- locale: const Locale (
177
- 'en' ,
178
- 'US' ,
179
- ), // translations will be displayed in that locale
194
+ locale: _getLocale (), // translations will be displayed in that locale
180
195
fallbackLocale: const Locale (
181
196
'en' ,
182
- 'UK ' ,
197
+ 'US ' ,
183
198
), // specify the fallback locale in case an invalid locale is selected.
184
199
title: 'POAPin' ,
185
200
theme: ThemeData (
You can’t perform that action at this time.
0 commit comments