fromSource static method

MapEventWithMove? fromSource({
  1. required LatLng targetCenter,
  2. required double targetZoom,
  3. required LatLng oldCenter,
  4. required double oldZoom,
  5. required bool hasGesture,
  6. required MapEventSource source,
  7. String? id,
})

Returns a subclass of MapEventWithMove if the source belongs to a movement event, otherwise returns null.

Implementation

static MapEventWithMove? fromSource({
  required LatLng targetCenter,
  required double targetZoom,
  required LatLng oldCenter,
  required double oldZoom,
  required bool hasGesture,
  required MapEventSource source,
  String? id,
}) =>
    switch (source) {
      MapEventSource.flingAnimationController => MapEventFlingAnimation(
          center: oldCenter,
          zoom: oldZoom,
          targetCenter: targetCenter,
          targetZoom: targetZoom,
          source: source,
        ),
      MapEventSource.doubleTapZoomAnimationController =>
        MapEventDoubleTapZoom(
          center: oldCenter,
          zoom: oldZoom,
          targetCenter: targetCenter,
          targetZoom: targetZoom,
          source: source,
        ),
      MapEventSource.scrollWheel => MapEventScrollWheelZoom(
          center: oldCenter,
          zoom: oldZoom,
          targetCenter: targetCenter,
          targetZoom: targetZoom,
          source: source,
        ),
      MapEventSource.onDrag ||
      MapEventSource.onMultiFinger ||
      MapEventSource.mapController ||
      MapEventSource.custom =>
        MapEventMove(
          id: id,
          center: oldCenter,
          zoom: oldZoom,
          targetCenter: targetCenter,
          targetZoom: targetZoom,
          source: source,
        ),
      _ => null,
    };