toMap method

Map<String, dynamic> toMap()

Converts the IndianState object into a Map.

The 'cities' field is converted into a list of maps.

Implementation

Map<String, dynamic> toMap() {
  return {
    'name': name,
    'code': code,
    'capital': capital,
    'population': population,
    'area': area,
    'image': image,
    'cities': cities.map((city) => city.toMap()).toList(),
  };
}