passo_mobile_app/lib/model/location/provinces.dart

50 lines
1.2 KiB
Dart
Raw Normal View History

2023-02-15 03:40:12 +00:00
// To parse this JSON data, do
//
// final province = provinceFromJson(jsonString);
import 'package:meta/meta.dart';
import 'dart:convert';
2023-02-16 07:10:54 +00:00
import 'region.dart';
2023-02-15 03:40:12 +00:00
Province provinceFromJson(String str) => Province.fromJson(json.decode(str));
String provinceToJson(Province data) => json.encode(data.toJson());
class Province {
Province({
required this.code,
required this.description,
required this.region,
required this.psgcCode,
required this.shortname,
});
final String? code;
final String? description;
final Region? region;
final String? psgcCode;
final String? shortname;
2023-02-15 03:40:12 +00:00
factory Province.fromJson(Map<String, dynamic> json) => Province(
code: json["code"],
description: json["description"],
region: json['region'] == null? null: Region.fromJson(json["region"]),
2023-02-15 03:40:12 +00:00
psgcCode: json["psgc_code"],
shortname: json["shortname"],
);
Map<String, dynamic> toJson() => {
"code": code,
"description": description,
"region": region!.toJson(),
2023-02-15 03:40:12 +00:00
"psgc_code": psgcCode,
"shortname": shortname,
};
2023-02-27 06:26:27 +00:00
@override
String toString(){
return 'Province(name:$description ${region.toString()})';
}
2023-02-15 03:40:12 +00:00
}