Created
June 7, 2025 04:49
-
-
Save rubywai/609f1451f6a0fd854c3d86c4e148b7d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:json_annotation/json_annotation.dart'; | |
part 'city_model.g.dart'; | |
@JsonSerializable() | |
class CityModel { | |
final List<CitySearchModel> results; | |
CityModel({required this.results}); | |
factory CityModel.fromJson(Map<String, dynamic> json) => | |
_$CityModelFromJson(json); | |
Map<String, dynamic> toJson() => _$CityModelToJson(this); | |
} | |
@JsonSerializable() | |
class CitySearchModel { | |
final num id; | |
final String name; | |
final double latitude; | |
final double longitude; | |
final String country; | |
CitySearchModel({ | |
required this.id, | |
required this.name, | |
required this.latitude, | |
required this.longitude, | |
required this.country, | |
}); | |
factory CitySearchModel.fromJson(Map<String, dynamic> json) => | |
_$CitySearchModelFromJson(json); | |
Map<String, dynamic> toJson() => _$CitySearchModelToJson(this); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment