diff --git a/bin/internal/engine.version b/bin/internal/engine.version index 6c3c7fadbc..15fb23e2a9 100644 --- a/bin/internal/engine.version +++ b/bin/internal/engine.version @@ -1 +1 @@ -4c79e423dc6f89f98d8ceb263a5ca78e2f2da996 +cdd592f5be97e8245b31d7621bc95234b62c3a43 diff --git a/bin/internal/goldens.version b/bin/internal/goldens.version index 754ef3ec41..a4aae1372f 100644 --- a/bin/internal/goldens.version +++ b/bin/internal/goldens.version @@ -1 +1 @@ -2a4133039bc4f59613a73a6d871a7c0e6f2396fa +afef1dc571f94a41751917d3946defba782335f7 diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 15c9de9ed5..af00037a1f 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -678,14 +678,16 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv Locale _locale; Locale _resolveLocale(Locale newLocale, Iterable supportedLocales) { - if (newLocale == null) { - return supportedLocales.first; - } if (widget.localeResolutionCallback != null) { final Locale locale = widget.localeResolutionCallback(newLocale, widget.supportedLocales); if (locale != null) return locale; } + // newLocale can be null when called before the platform has had a chance to + // initialize the locales. We default to the first supported locale. + if (newLocale == null) { + return supportedLocales.first; + } Locale matchesLanguageCode; for (Locale locale in supportedLocales) { diff --git a/packages/flutter_localizations/test/widgets_test.dart b/packages/flutter_localizations/test/widgets_test.dart index efc8fc6aba..1a2923f07c 100644 --- a/packages/flutter_localizations/test/widgets_test.dart +++ b/packages/flutter_localizations/test/widgets_test.dart @@ -537,7 +537,7 @@ void main() { ) ); - // Startup time. Default test locale is const Locale('', ''), so + // Startup time. Default test locale is null, so // no supported matches. Use the first locale. await tester.pumpAndSettle(); expect(find.text('zh_CN'), findsOneWidget); @@ -581,9 +581,10 @@ void main() { ) ); - // Initial WidgetTester locale is new Locale('', '') + // Initial WidgetTester locale is null due to no platform intitializing it. + // The locale gets resolved to "en_US", which is the first supported locale. await tester.pumpAndSettle(); - expect(find.text('_ TextDirection.ltr'), findsOneWidget); + expect(find.text('en_US TextDirection.ltr'), findsOneWidget); await tester.binding.setLocale('en', 'CA'); await tester.pumpAndSettle(); @@ -622,9 +623,10 @@ void main() { ) ); - // Initial WidgetTester locale is new Locale('', '') + // Initial WidgetTester locale is null due to no platform intitializing it. + // The locale gets resolved to "en_US", which is the first supported locale. await tester.pumpAndSettle(); - expect(find.text('_ TextDirection.rtl'), findsOneWidget); + expect(find.text('en_US TextDirection.rtl'), findsOneWidget); await tester.binding.setLocale('en', 'CA'); await tester.pumpAndSettle(); @@ -655,9 +657,10 @@ void main() { ) ); - // Initial WidgetTester locale is new Locale('', '') + // Initial WidgetTester locale is null due to no platform intitializing it. + // The locale gets resolved to "en_US", which is the first supported locale. await tester.pumpAndSettle(); - expect(find.text('_ TextDirection.rtl'), findsOneWidget); + expect(find.text('en_US TextDirection.rtl'), findsOneWidget); await tester.binding.setLocale('en', 'CA'); await tester.pumpAndSettle();