Rain/lib/app/api/city_api.dart

34 lines
720 B
Dart
Raw Normal View History

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