Rain/lib/app/api/city_api.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-17 20:53:23 +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))),
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-17 20:53:23 +03:00
admin1: json['admin1'] ?? '',
name: json['name'],
latitude: json['latitude'],
longitude: json['longitude'],
2023-06-17 20:57:57 +03:00
);
}