Rain/lib/app/api/city.dart

35 lines
749 B
Dart
Raw Normal View History

2023-06-17 20:57:57 +03:00
class CityApi {
CityApi({
required this.results,
});
List<Result> results;
factory CityApi.fromJson(Map<String, dynamic> json) => CityApi(
2023-07-09 12:56:16 +05:30
results: json["results"] == null
? List<Result>.empty()
: List<Result>.from(json["results"].map((x) => Result.fromJson(x))),
2023-06-17 20:57:57 +03:00
);
}
class Result {
Result({
required this.admin1,
required this.name,
required this.latitude,
required this.longitude,
});
String admin1;
String name;
double latitude;
double longitude;
factory Result.fromJson(Map<String, dynamic> json) => Result(
2023-07-09 12:56:16 +05:30
admin1: json["admin1"] ?? '',
2023-06-17 20:57:57 +03:00
name: json["name"],
latitude: json["latitude"],
longitude: json["longitude"],
);
}