getCountryByCountryCode function

Future<Country?> getCountryByCountryCode(
  1. BuildContext context,
  2. String countryCode
)

This function returns an country whose countryCode matches with the passed one.

Implementation

Future<Country?> getCountryByCountryCode(
    BuildContext context, String countryCode) async {
  final list = await getCountries(context);
  return list.firstWhere((element) => element.countryCode == countryCode);
}