getByName static method

CountryModel? getByName(
  1. String name, {
  2. List<CountryModel>? allowedCountryList,
})

Implementation

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