From aae6632963030cd2fa93f6fafc97042a8c95875c Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 9 Feb 2023 17:35:45 +0100 Subject: [PATCH] Only check that the language code matches Otherwise, both the language code and the country code would need to match --- lib/main.dart | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 94aa08b2..252ba121 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -157,8 +157,15 @@ class MyApp extends StatelessWidget { // Workaround for https://github.com/flutter/flutter/issues/100857 localeResolutionCallback: (deviceLocale, supportedLocales) { - if (supportedLocales.contains(deviceLocale)) { - return deviceLocale; + if (deviceLocale != null) { + for (final supportedLocale in supportedLocales) { + // Since we currently don't support any country specific locales + // such as de-DE and de-AT, it's sufficient to just check it like + // this. Otherwise we will need more logic with .countryCode + if (supportedLocale.languageCode == deviceLocale.languageCode) { + return supportedLocale; + } + } } return const Locale('en'); },