geopointFromMap static method

  1. @visibleForTesting
GeoPoint? geopointFromMap({
  1. required String field,
  2. required Map<String, dynamic> snapData,
})

Implementation

@visibleForTesting
static GeoPoint? geopointFromMap({
  required String field,
  required Map<String, dynamic> snapData,
}) {
  // split and fetch geoPoint from the nested Map
  final fieldList = field.split('.');
  Map<dynamic, dynamic>? geoPointField = snapData[fieldList[0]];
  if (fieldList.length > 1) {
    for (int i = 1; i < fieldList.length; i++) {
      geoPointField = geoPointField?[fieldList[i]];
    }
  }
  return geoPointField?['geopoint'] as GeoPoint?;
}