GeoPoint.fromNative constructor

GeoPoint.fromNative(
  1. Map<Object?, Object?> data
)

Construct a GeoPoint from the given data.

If the data does not contain valid GeoPoint coordinates, then 0,0 is returned.

Implementation

factory GeoPoint.fromNative(Map<Object?, Object?> data) {
  final latitude = data['latitude'] as double?;
  final longitude = data['longitude'] as double?;

  // If either is not set, then this GeoPoint is invalid.
  // Return the geographic center as fallback.
  if (latitude == null || longitude == null) {
    return const GeoPoint(latitude: 0, longitude: 0);
  }

  return GeoPoint(latitude: latitude, longitude: longitude);
}