Skip to content

Commit aae6632

Browse files
committed
Only check that the language code matches
Otherwise, both the language code and the country code would need to match
1 parent 16cdd6c commit aae6632

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/main.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,15 @@ class MyApp extends StatelessWidget {
157157

158158
// Workaround for https://github.com/flutter/flutter/issues/100857
159159
localeResolutionCallback: (deviceLocale, supportedLocales) {
160-
if (supportedLocales.contains(deviceLocale)) {
161-
return deviceLocale;
160+
if (deviceLocale != null) {
161+
for (final supportedLocale in supportedLocales) {
162+
// Since we currently don't support any country specific locales
163+
// such as de-DE and de-AT, it's sufficient to just check it like
164+
// this. Otherwise we will need more logic with .countryCode
165+
if (supportedLocale.languageCode == deviceLocale.languageCode) {
166+
return supportedLocale;
167+
}
168+
}
162169
}
163170
return const Locale('en');
164171
},

0 commit comments

Comments
 (0)