Language.parse constructor

Language.parse(
  1. String text
)

Implementation

factory Language.parse(String text) {
  if (!matches(text)) {
    throw ArgumentError('Invalid format for language $text');
  }

  final code = text.substring(0, 2);
  final country = text.substring(3);
  return Language(code, country);
}