// To parse this JSON data, do // // final cityResponse = cityResponseFromJson(jsonString); import 'dart:convert'; CityResponse cityResponseFromJson(String str) => CityResponse.fromJson(json.decode(str)); String cityResponseToJson(CityResponse data) => json.encode(data.toJson()); class CityResponse { List data; CityResponse({ required this.data, }); factory CityResponse.fromJson(Map json) => CityResponse( data: List.from(json["data"].map((x) => CityInfo.fromJson(x))), ); Map toJson() => { "data": List.from(data.map((x) => x.toJson())), }; } class CityInfo { int stateId; int id; String name; bool isActive; CityInfo({ required this.stateId, required this.id, required this.name, required this.isActive, }); factory CityInfo.fromJson(Map json) => CityInfo( stateId: json["state_id"], id: json["id"], name: json["name"], isActive: json["is_active"], ); Map toJson() => { "state_id": stateId, "id": id, "name": name, "is_active": isActive, }; }