getByCallingCode static method

CountryModel? getByCallingCode(
  1. String callingCode, {
  2. List<CountryModel>? allowedCountryList,
})

Implementation

static CountryModel? getByCallingCode(String callingCode,
    {List<CountryModel>? allowedCountryList}) {
  try {
    return (allowedCountryList ?? countryList)
        .firstWhere((country) => country.callingCode == callingCode);
  } catch (e) {
    return null;
  }
}