Locale class Null safety

A representation of a Unicode Locale Identifier.

To create Locale instances, consider using:

  • fromSubtags for language, script and region,
  • parse for Unicode Locale Identifier strings (throws exceptions on failure),
  • tryParse for Unicode Locale Identifier strings (returns null on failure).

Constructors

Locale()

Properties

countryCode → String?
The region subtag of the Locale Identifier, null if absent.
read-only
hashCode → int
The hash code for this object.
read-onlyoverride
languageCode → String
The language subtag of the Locale Identifier.
read-only
runtimeType → Type
A representation of the runtime type of the object.
read-onlyinherited
scriptCode → String?
The script subtag of the Locale Identifier, null if absent.
read-only
variants → Iterable<String>
Iterable of variant subtags.
read-only

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toLanguageTag() → String
Returns the canonical Unicode BCP47 Locale Identifier for this locale.
toString() → String
Returns the canonical Unicode BCP47 Locale Identifier for this locale.
override

Operators

operator ==(Object other) → bool
The equality operator.
override

Static Methods

fromSubtags({required String languageCode, String? scriptCode, String? countryCode}) → Locale
Constructs a Locale instance that consists of only language, script and region subtags.
parse(String localeIdentifier) → Locale
Parses Unicode Locale Identifiers to produce Locale instances.
tryParse(String localeIdentifier) → Locale?
Parses Unicode Locale Identifiers to produce Locale instances.