35 lines
759 B
Dart
35 lines
759 B
Dart
import 'latlng.dart';
|
|
|
|
class Location {
|
|
final String name;
|
|
final LatLng coordinates;
|
|
final String 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 {
|
|
'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;
|
|
}
|