Language.fromString constructor

Language.fromString(
  1. String? source
)

Returns a new Language from a string language code. If the string is not a valid Unicode Locale Identifiers it defaults to Language.all.

Implementation

factory Language.fromString(String? source) {
  if (source == null) return Language.all;
  final locale = Locale.tryParse(source);
  return locale != null ? Language.other(locale) : Language.all;
}