getCountryCities function

Future<List<City>> getCountryCities(
  1. String countryCode
)

Get the list of cities that belongs to a country by the country ISO CODE

Implementation

Future<List<City>> getCountryCities(String countryCode) async {
  final cities = await _loadCities();

  final res = cities.where((city) {
    return city.countryCode == countryCode;
  }).toList();
  res.sort((a, b) => a.name.compareTo(b.name));

  return res;
}