Skip to content

Commit 179b6b5

Browse files
authored
fix: ensure movement gestures emit events when starting (#2035)
1 parent e9272e2 commit 179b6b5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/src/gestures/map_interactive_viewer.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
528528
void _handleScaleStart(ScaleStartDetails details) {
529529
_dragMode = _pointerCounter == 1;
530530

531+
// This is not always emitted publicly - see #1939!
531532
final eventSource = _dragMode
532533
? MapEventSource.dragStart
533534
: MapEventSource.multiFingerGestureStart;
@@ -572,23 +573,21 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
572573
void _handleScaleDragUpdate(ScaleUpdateDetails details) {
573574
if (_ckrTriggered.value) return;
574575

575-
const eventSource = MapEventSource.onDrag;
576-
577576
if (InteractiveFlag.hasDrag(_interactionOptions.flags)) {
578577
if (!_dragStarted) {
579578
// We could emit start event at [handleScaleStart], however it is
580579
// possible drag will be disabled during ongoing drag then
581580
// [didUpdateWidget] will emit MapEventMoveEnd and if drag is enabled
582581
// again then this will emit the start event again.
583582
_dragStarted = true;
584-
widget.controller.moveStarted(eventSource);
583+
widget.controller.moveStarted(MapEventSource.dragStart);
585584
}
586585

587586
final localDistanceOffset = _rotateOffset(
588587
_lastFocalLocal - details.localFocalPoint,
589588
);
590589

591-
widget.controller.dragUpdated(eventSource, localDistanceOffset);
590+
widget.controller.dragUpdated(MapEventSource.onDrag, localDistanceOffset);
592591
}
593592
}
594593

@@ -654,7 +653,7 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
654653
if (!_pinchMoveStarted) {
655654
// We want to call moveStart only once for a movement so don't call
656655
// it if a pinch move is already underway.
657-
widget.controller.moveStarted(MapEventSource.onMultiFinger);
656+
widget.controller.moveStarted(MapEventSource.multiFingerGestureStart);
658657
}
659658
}
660659
}
@@ -669,7 +668,7 @@ class MapInteractiveViewerState extends State<MapInteractiveViewer>
669668
if (!_pinchZoomStarted) {
670669
// We want to call moveStart only once for a movement so don't call
671670
// it if a pinch zoom is already underway.
672-
widget.controller.moveStarted(MapEventSource.onMultiFinger);
671+
widget.controller.moveStarted(MapEventSource.multiFingerGestureStart);
673672
}
674673
}
675674
}

0 commit comments

Comments
 (0)