passo_mobile_app/lib/model/passo/city.dart

47 lines
1.1 KiB
Dart
Raw Normal View History

2023-09-01 03:22:48 +00:00
// To parse this JSON data, do
//
// final city = cityFromJson(jsonString);
import 'dart:convert';
City cityFromJson(String str) => City.fromJson(json.decode(str));
String cityToJson(City data) => json.encode(data.toJson());
class City {
final int? id;
2023-09-01 03:22:48 +00:00
final String? cityCode;
final String? cityDescription;
City({
this.id,
2023-09-01 03:22:48 +00:00
this.cityCode,
this.cityDescription,
});
City copy({int? id, String? cityCode, String? cityDescription}) {
return City(
id: id ?? this.id,
cityCode: cityCode ?? this.cityCode,
cityDescription: cityDescription ?? this.cityDescription);
}
2023-09-01 03:22:48 +00:00
factory City.fromJson(Map<String, dynamic> json) => City(
id: json["id"],
2023-09-01 03:22:48 +00:00
cityCode: json["city_code"],
cityDescription: json["city_description"],
);
factory City.fromJson2(Map<String, dynamic> json) => City(
id: json["id"],
cityCode: json["cityCode"],
cityDescription: json["cityDescription"],
);
2023-09-01 03:22:48 +00:00
Map<String, dynamic> toJson() => {
"id": id,
2023-09-01 03:22:48 +00:00
"city_code": cityCode,
"city_description": cityDescription,
};
}