getLocationValue static method

GeoPoint? getLocationValue(
  1. DocumentSnapshot<Object?> documentSnapshot
)

Build a GeoPoint from a documentSnapshot

Implementation

static GeoPoint? getLocationValue(DocumentSnapshot documentSnapshot) {
  try {
    final data = documentSnapshot.data() as Map<String, dynamic>;
    if (data != null && data['l'] != null) {
      final location = data['l'];
      final latitude = location[0];
      final longitude = location[1];
      if (GeoUtils.coordinatesValid(latitude, longitude)) {
        return location;
      }
    }
    return null;
  } catch (e) {
    print('Error occurred when getLocationValue: ' + e.toString());
    return null;
  }
}