CountryDialCode.fromCountryCode constructor
CountryDialCode.fromCountryCode(
- String countryCode
Returns a CountryDialCode class by ISO 3166 Alpha-2 countryCode
.
Throw a CountryNotFoundException if the country does not exist.
Implementation
factory CountryDialCode.fromCountryCode(String countryCode) {
final Map<String, String> country = dialCodes.firstWhere(
(code) => code['code'] == countryCode.toUpperCase(),
orElse: () => {},
);
if (country.isEmpty) throw const CountryNotFoundException();
return CountryDialCode.fromJson(country);
}