getCityById method

Future<CityModel?> getCityById(
  1. String id
)

Implementation

Future<CityModel?> getCityById(String id) async {
  final cities = await loadCities();
  try {
    return cities.firstWhere((city) => city.id == id);
  } catch (e) {
    return null;
  }
}