getByCountryCode static method

CountryModel? getByCountryCode(
  1. String code, {
  2. List<CountryModel>? allowedCountryList,
})

Implementation

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