LocaleImplementation.unsafe constructor

LocaleImplementation.unsafe(
  1. String languageCode, {
  2. String? scriptCode,
  3. String? countryCode,
  4. Iterable<String>? variants,
  5. LocaleExtensions? extensions,
})

Simple factory which assumes parameters are syntactically correct.

In debug mode, incorrect use may result in an assertion failure. (In production code, this class makes no promises regarding the consequence of incorrect use.)

For public APIs, see Locale.fromSubtags and Locale.parse.

Implementation

factory LocaleImplementation.unsafe(
  String languageCode, {
  String? scriptCode,
  String? countryCode,
  Iterable<String>? variants,
  LocaleExtensions? extensions,
}) {
  variants = (variants != null && variants.isNotEmpty)
      ? List.unmodifiable(variants.toList()..sort())
      : const [];
  return LocaleImplementation._(
      languageCode, scriptCode, countryCode, variants, extensions);
}