Location overview screen and model changes #3

Merged
marco merged 9 commits from development into main 2026-06-19 14:03:45 +02:00
2 changed files with 31 additions and 2 deletions
Showing only changes of commit a71cc454eb - Show all commits
+14
View File
@@ -12,4 +12,18 @@ class LatLng {
Map<String, double> toJson() {
return {'lat': lat, 'lng': lng};
}
@override
bool operator ==(Object other) {
if (other is! LatLng) return false;
return hashCode == other.hashCode;
}
@override
int get hashCode => Object.hash(lat, lng);
@override
String toString() {
return '${lat.toString()}, ${lng.toString()}';
}
}
+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;
}