Locale.fromSubtags constructor Null safety

const Locale.fromSubtags(
  1. {String languageCode = 'und',
  2. String? scriptCode,
  3. String? countryCode}
)

Creates a new Locale object.

The keyword arguments specify the subtags of the Locale.

The subtag values are case sensitive and must be valid subtags according to CLDR supplemental data: language, script and region for each of languageCode, scriptCode and countryCode respectively.

The languageCode subtag is optional. When there is no language subtag, the parameter should be omitted or set to "und". When not supplied, the languageCode defaults to "und", an undefined language code.

The countryCode subtag is optional. When there is no country subtag, the parameter should be omitted or passed null instead of an empty-string.

Validity is not checked by default, but some methods may throw away invalid data.

Implementation

const Locale.fromSubtags({
  String languageCode = 'und',
  this.scriptCode,
  String? countryCode,
}) : assert(languageCode != null),
     assert(languageCode != ''),
     _languageCode = languageCode,
     assert(scriptCode != ''),
     assert(countryCode != ''),
     _countryCode = countryCode;