getCities function

Future<List<ItalianCities>> getCities()

Implementation

Future<List<ItalianCities>> getCities() async {
  final jsonData =
      await rootBundle.loadString('assets/data/italian_cities.json');
  final data = json.decode(jsonData);
  List<ItalianCities> cities = [];
  for (var i = 0; i < data.length; i++) {
    cities.add(ItalianCities(
      city: data[i]['city'],
      lat: data[i]['lat'],
      lng: data[i]['lng'],
    ));
  }
  return cities;
}