IndianState.fromMap constructor

IndianState.fromMap(
  1. Map<String, dynamic> map
)

Factory method to create an IndianState object from a Map.

The map must contain the keys: 'name', 'code', 'capital', 'population', 'image', and 'cities'. The 'cities' key should be a list of city maps.

Implementation

factory IndianState.fromMap(Map<String, dynamic> map) {
  return IndianState(
    name: map['name'] as String,
    code: map['code'] as String,
    image: map['image'] as String,
    capital: map['capital'] as String,
    population: map['population'] as String,
    area: map['area'] as String,
    cities: (map['cities'] as List)
        .map((cityMap) => City.fromMap(cityMap as Map<String, String>))
        .toList(),
  );
}