Location overview screen and model changes #3
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user