Fix bug for calling isEmpty on null object. (#16782)
This commit is contained in:
@@ -133,8 +133,7 @@ class GlobalMaterialLocalizations implements MaterialLocalizations {
|
||||
intl.DateFormat _yearMonthFormat;
|
||||
|
||||
static String _computeLocaleName(Locale locale) {
|
||||
final String localeName = locale.countryCode.isEmpty ? locale.languageCode : locale.toString();
|
||||
return intl.Intl.canonicalizedLocale(localeName);
|
||||
return intl.Intl.canonicalizedLocale(locale.toString());
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -47,6 +47,28 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pumpWidget(new Container());
|
||||
});
|
||||
|
||||
testWidgets('Locale without coutryCode', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/pull/16782
|
||||
await tester.pumpWidget(
|
||||
new MaterialApp(
|
||||
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const <Locale>[
|
||||
const Locale('es', 'ES'),
|
||||
const Locale('zh'),
|
||||
],
|
||||
home: new Container(),
|
||||
)
|
||||
);
|
||||
|
||||
await tester.binding.setLocale('zh', null);
|
||||
await tester.pump();
|
||||
await tester.binding.setLocale('es', 'US');
|
||||
await tester.pump();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// A localizations delegate that does not contain any useful data, and is only
|
||||
|
||||
Reference in New Issue
Block a user