getInitialSelectedCountry method Null safety

Country getInitialSelectedCountry(
  1. List<Country> countries,
  2. String countryCode
)

Returns a Country form list of countries passed that matches countryCode. Returns the first Country in the list if no match is available.

Implementation

static Country getInitialSelectedCountry(
    List<Country> countries, String countryCode) {
  return countries.firstWhere((country) => country.alpha2Code == countryCode,
      orElse: () => countries[0]);
}