Unverified Commit 02d659e8 authored by Gary Qian's avatar Gary Qian Committed by GitHub

Support null locale before locale initialization, Roll engine to cdd592f5be97e824 (#23417)

cdd592f5b Reland 'Pass null instead of 'none' locale' (#6632)
2cd89200c Roll src/third_party/skia b1a002e850e1..327955b1ba19 (12 commits) (#6631)
edfe02481 13771 - iOS dictation bug (#6607)
cadf4405b Roll src/third_party/skia b9998cdceec7..b1a002e850e1 (13 commits) (#6626)
parent 65d3ddd5
4c79e423dc6f89f98d8ceb263a5ca78e2f2da996
cdd592f5be97e8245b31d7621bc95234b62c3a43
2a4133039bc4f59613a73a6d871a7c0e6f2396fa
afef1dc571f94a41751917d3946defba782335f7
......@@ -678,14 +678,16 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
Locale _locale;
Locale _resolveLocale(Locale newLocale, Iterable<Locale> 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) {
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment