mapToEvent static method

GeolocationEvent mapToEvent(
  1. dynamic raw
)

Converts a raw native event to a typed GeolocationEvent.

Implementation

static GeolocationEvent<dynamic> mapToEvent(dynamic raw) {
  if (raw is Map) {
    final map = deepMap(raw);
    if (map.containsKey('type')) {
      return GeolocationEvent.fromMap(map);
    }
    if (map.containsKey('coords')) {
      return GeolocationEvent<Location>(
        type: EventType.location,
        data: Location.fromMap(map),
      );
    }
  }
  return GeolocationEvent<dynamic>(type: EventType.unknown, data: raw);
}