location_reading.dart 628 B

12345678910111213141516171819202122
  1. /// A one-shot location fix plus a best-effort place label.
  2. class LocationReading {
  3. const LocationReading({
  4. required this.latitude,
  5. required this.longitude,
  6. required this.place,
  7. });
  8. final double latitude;
  9. final double longitude;
  10. final String place;
  11. factory LocationReading.fromMap(Map<dynamic, dynamic> map) {
  12. return LocationReading(
  13. latitude: (map['latitude'] as num?)?.toDouble() ?? 0,
  14. longitude: (map['longitude'] as num?)?.toDouble() ?? 0,
  15. place: ((map['place'] as String?) ?? '').trim(),
  16. );
  17. }
  18. String get displayPlace => place.isEmpty ? 'Current location' : place;
  19. }