getStatesOfCountry function

Future<List<State>> getStatesOfCountry(
  1. String countryCode
)

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

Implementation

Future<List<State>> getStatesOfCountry(String countryCode) async {
  final states = await _loadStates();

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

  return res;
}