getStateCities function

Future<List<City>> getStateCities(
  1. String countryCode,
  2. String stateCode
)

Get the list of states that belongs to a state by the state ISO CODE and the country ISO CODE

Implementation

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

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

  return res;
}