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