getCountry static method

Country getCountry(
  1. String phoneNumber
)

Implementation

static Country getCountry(String phoneNumber) {
  if (phoneNumber == "") {
    throw NumberTooShortException();
  }

  if (phoneNumber.startsWith('+')) {
    return countries.firstWhere((country) => phoneNumber
        .substring(1)
        .startsWith(country.dialCode + country.regionCode));
  }
  return countries.firstWhere((country) =>
      phoneNumber.startsWith(country.dialCode + country.regionCode));
}