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) {
    case MapEventSource.flingAnimationController:
      return MapEventFlingAnimation(
        center: oldCenter,
        zoom: oldZoom,
        targetCenter: targetCenter,
        targetZoom: targetZoom,
        source: source,
      );
    case MapEventSource.doubleTapZoomAnimationController:
      return MapEventDoubleTapZoom(
        center: oldCenter,
        zoom: oldZoom,
        targetCenter: targetCenter,
        targetZoom: targetZoom,
        source: source,
      );
    case MapEventSource.scrollWheel:
      return MapEventScrollWheelZoom(
        center: oldCenter,
        zoom: oldZoom,
        targetCenter: targetCenter,
        targetZoom: targetZoom,
        source: source,
      );
    case MapEventSource.onDrag:
    case MapEventSource.onMultiFinger:
    case MapEventSource.mapController:
    case MapEventSource.custom:
      return MapEventMove(
        id: id,
        center: oldCenter,
        zoom: oldZoom,
        targetCenter: targetCenter,
        targetZoom: targetZoom,
        source: source,
      );
    default:
      return null;
  }
}