From 8aa660437fa3ed098ecd1fb1462a80e87a36d1fc Mon Sep 17 00:00:00 2001 From: Shreyas Thirumalai Date: Tue, 5 Jan 2021 17:02:42 +0530 Subject: [PATCH] fix: fallback language (#141) fixes #140 --- lib/app.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 0c2756f..7c8ffcb 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -17,7 +17,12 @@ class MyApp extends StatelessWidget { home: Home(), localeResolutionCallback: (Locale locale, Iterable supportedLocales) { - return locale; + for (final supportedLocale in supportedLocales) { + if (locale.languageCode == supportedLocale.languageCode) { + return supportedLocale; + } + } + return supportedLocales.first; }, localizationsDelegates: [ S.delegate, @@ -47,7 +52,12 @@ class MyApp extends StatelessWidget { home: Home(), localeResolutionCallback: (Locale locale, Iterable supportedLocales) { - return locale; + for (final supportedLocale in supportedLocales) { + if (locale.languageCode == supportedLocale.languageCode) { + return supportedLocale; + } + } + return supportedLocales.first; }, localizationsDelegates: [ S.delegate,