passo_mobile_app/lib/model/location/city.dart

52 lines
1.4 KiB
Dart
Raw Normal View History

2023-02-15 03:40:12 +00:00
// To parse this JSON data, do
//
// final city = cityFromJson(jsonString);
import 'package:meta/meta.dart';
import 'dart:convert';
2023-02-20 07:48:24 +00:00
import 'provinces.dart';
import 'region.dart';
2023-02-15 03:40:12 +00:00
2023-02-20 07:48:24 +00:00
CityMunicipality cityFromJson(String str) => CityMunicipality.fromJson(json.decode(str));
2023-02-15 03:40:12 +00:00
2023-02-20 07:48:24 +00:00
String cityToJson(CityMunicipality data) => json.encode(data.toJson());
class CityMunicipality {
CityMunicipality({
2023-02-15 03:40:12 +00:00
required this.code,
required this.description,
required this.province,
required this.psgcCode,
required this.zipcode,
});
final String? code;
final String? description;
final Province? province;
final String? psgcCode;
final String? zipcode;
2023-02-15 03:40:12 +00:00
2023-02-20 07:48:24 +00:00
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
2023-02-15 03:40:12 +00:00
code: json["code"],
description: json["description"],
province: json['province'] == null? null : Province.fromJson(json["province"]),
2023-02-15 03:40:12 +00:00
psgcCode: json["psgc_code"],
zipcode: json["zipcode"],
);
Map<String, dynamic> toJson() => {
"code": code,
"description": description,
2023-02-27 06:26:27 +00:00
"province": province?.toJson(),
2023-02-15 03:40:12 +00:00
"psgc_code": psgcCode,
"zipcode": zipcode,
};
2023-02-27 06:26:27 +00:00
@override
String toString(){
return 'CityMunicipality{code:$code, description:$description, provice:${province.toString()} }';
}
2023-02-15 03:40:12 +00:00
}