extended location and latlng models

This commit is contained in:
2026-06-19 13:21:08 +02:00
parent f1c1578620
commit a71cc454eb
2 changed files with 31 additions and 2 deletions
+17 -2
View File
@@ -1,19 +1,34 @@
import 'latlng.dart';
class Location {
final String name;
final LatLng coordinates;
final String address;
Location({required this.coordinates, this.address = ''});
Location({required this.name, required this.coordinates, this.address = ''});
factory Location.fromJson(Map<String, dynamic> json) {
return Location(
name: json['name'] as String,
address: json['address'] as String,
coordinates: LatLng.fromJson(json['coordinates']),
);
}
Map<String, dynamic> toJson() {
return {'address': address, 'coordinates': coordinates.toJson()};
return {
'name': name,
'address': address,
'coordinates': coordinates.toJson(),
};
}
@override
bool operator ==(Object other) {
if (other is! Location) return false;
return hashCode == other.hashCode;
}
@override
int get hashCode => coordinates.hashCode;
}