ofAlpha static method

CountryCode ofAlpha(
  1. String code
)

Returns country by Alpha-2 or Alpha-3 code Throws ArgumentError if the code is invalid or there is no ISO- or user-assigned country for this code

Implementation

static CountryCode ofAlpha(String code) {
  int index;

  if (_userValues.isNotEmpty) {
    index = _parseAlpha(code, _userValues);
    if (index != -1) {
      return _userValues[index];
    }
  }

  index = _parseAlpha(code, _values);
  if (index != -1) {
    return _values[index];
  }

  throw ArgumentError('Alpha code \"$code\" is not assigned');
}