diff --git a/lib/ui/platform_dispatcher.dart b/lib/ui/platform_dispatcher.dart index f4840689031b0..d1cdca31c2d9f 100644 --- a/lib/ui/platform_dispatcher.dart +++ b/lib/ui/platform_dispatcher.dart @@ -1943,7 +1943,7 @@ class Locale { const Locale( this._languageCode, [ this._countryCode, - ]) : assert(_languageCode != ''), + ]) : assert(_languageCode.isNotEmpty), scriptCode = null; /// Creates a new Locale object. @@ -1970,10 +1970,10 @@ class Locale { String languageCode = 'und', this.scriptCode, String? countryCode, - }) : assert(languageCode != ''), + }) : assert(languageCode.isNotEmpty), _languageCode = languageCode, - assert(scriptCode != ''), - assert(countryCode != ''), + assert(scriptCode == null || scriptCode.isNotEmpty), + assert(countryCode == null || countryCode.isNotEmpty), _countryCode = countryCode; /// The primary language subtag for the locale. diff --git a/lib/web_ui/lib/platform_dispatcher.dart b/lib/web_ui/lib/platform_dispatcher.dart index a6db5dbb11c8b..68e0c10c93ad0 100644 --- a/lib/web_ui/lib/platform_dispatcher.dart +++ b/lib/web_ui/lib/platform_dispatcher.dart @@ -443,17 +443,17 @@ class Locale { const Locale( this._languageCode, [ this._countryCode, - ]) : assert(_languageCode != ''), + ]) : assert(_languageCode.isNotEmpty), scriptCode = null; const Locale.fromSubtags({ String languageCode = 'und', this.scriptCode, String? countryCode, - }) : assert(languageCode != ''), + }) : assert(languageCode.isNotEmpty), _languageCode = languageCode, - assert(scriptCode != ''), - assert(countryCode != ''), + assert(scriptCode == null || scriptCode.isNotEmpty), + assert(countryCode == null || countryCode.isNotEmpty), _countryCode = countryCode; String get languageCode => _deprecatedLanguageSubtagMap[_languageCode] ?? _languageCode;