GeoPoint.fromNative constructor
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 double? latitude = data['latitude'] as double?;
final double? 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.0, longitude: 0.0);
}
return GeoPoint(latitude: latitude, longitude: longitude);
}