mobileApplicationsKonectarApp/lib/model/location_model.dart

123 lines
2.8 KiB
Dart

// To parse this JSON data, do
//
// final welcome = welcomeFromJson(jsonString);
import 'dart:convert';
Locations welcomeFromJson(String str) => Locations.fromJson(json.decode(str));
String welcomeToJson(Locations data) => json.encode(data.toJson());
class Locations {
Location location;
Locations({
required this.location,
});
factory Locations.fromJson(Map<String, dynamic> json) => Locations(
location: Location.fromJson(json["location"]),
);
Map<String, dynamic> toJson() => {
"location": location.toJson(),
};
}
class Location {
List<Country> country;
List<States> state;
List<City> city;
Location({
required this.country,
required this.state,
required this.city,
});
factory Location.fromJson(Map<String, dynamic> json) => Location(
country:
List<Country>.from(json["country"].map((x) => Country.fromJson(x))),
state: List<States>.from(json["state"].map((x) => States.fromJson(x))),
city: List<City>.from(json["city"].map((x) => City.fromJson(x))),
);
Map<String, dynamic> toJson() => {
"country": List<dynamic>.from(country.map((x) => x.toJson())),
"state": List<dynamic>.from(state.map((x) => x.toJson())),
"city": List<dynamic>.from(city.map((x) => x.toJson())),
};
}
class City {
String cityName;
String distId;
String stateId;
String countryId;
City({
required this.cityName,
required this.distId,
required this.stateId,
required this.countryId,
});
factory City.fromJson(Map<String, dynamic> json) => City(
cityName: json["cityName"],
distId: json["distId"],
stateId: json["stateId"],
countryId: json["countryId"],
);
Map<String, dynamic> toJson() => {
"cityName": cityName,
"distId": distId,
"stateId": stateId,
"countryId": countryId,
};
}
class Country {
String countryName;
String countryId;
Country({
required this.countryName,
required this.countryId,
});
factory Country.fromJson(Map<String, dynamic> json) => Country(
countryName: json["countryName"],
countryId: json["countryId"],
);
Map<String, dynamic> toJson() => {
"countryName": countryName,
"countryId": countryId,
};
}
class States {
String stateName;
String stateId;
String countryId;
States({
required this.stateName,
required this.stateId,
required this.countryId,
});
factory States.fromJson(Map<String, dynamic> json) => States(
stateName: json["stateName"],
stateId: json["stateId"],
countryId: json["countryId"],
);
Map<String, dynamic> toJson() => {
"stateName": stateName,
"stateId": stateId,
"countryId": countryId,
};
}