@@ -309,15 +309,16 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
309309 }
310310 }
311311 if (event is PointerUpEvent || event is PointerCancelEvent ) {
312- _giveUpPointer (
313- event.pointer,
314- reject: event is PointerCancelEvent || _state == _DragState .possible,
315- );
312+ _giveUpPointer (event.pointer);
316313 }
317314 }
318315
316+ final Set <int > _acceptedActivePointers = < int > {};
317+
319318 @override
320319 void acceptGesture (int pointer) {
320+ assert (! _acceptedActivePointers.contains (pointer));
321+ _acceptedActivePointers.add (pointer);
321322 if (_state != _DragState .accepted) {
322323 _state = _DragState .accepted;
323324 final OffsetPair delta = _pendingDragOffset;
@@ -384,32 +385,36 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
384385 _state = _DragState .ready;
385386 }
386387
387- void _giveUpPointer (int pointer, { bool reject = true } ) {
388+ void _giveUpPointer (int pointer) {
388389 stopTrackingPointer (pointer);
389- if (reject)
390+ // If we never accepted the pointer, we reject it since we are no longer
391+ // interested in winning the gesture arena for it.
392+ if (! _acceptedActivePointers.remove (pointer))
390393 resolvePointer (pointer, GestureDisposition .rejected);
391394 }
392395
393396 void _checkDown () {
394397 assert (_initialButtons == kPrimaryButton);
395- final DragDownDetails details = DragDownDetails (
396- globalPosition : _initialPosition.global,
397- localPosition : _initialPosition.local ,
398- );
399- if (onDown != null )
398+ if (onDown != null ) {
399+ final DragDownDetails details = DragDownDetails (
400+ globalPosition : _initialPosition.global ,
401+ localPosition : _initialPosition.local,
402+ );
400403 invokeCallback <void >('onDown' , () => onDown !(details));
404+ }
401405 }
402406
403407 void _checkStart (Duration timestamp, int pointer) {
404408 assert (_initialButtons == kPrimaryButton);
405- final DragStartDetails details = DragStartDetails (
406- sourceTimeStamp : timestamp,
407- globalPosition : _initialPosition.global ,
408- localPosition : _initialPosition.local ,
409- kind : getKindForPointer (pointer) ,
410- );
411- if (onStart != null )
409+ if (onStart != null ) {
410+ final DragStartDetails details = DragStartDetails (
411+ sourceTimeStamp : timestamp ,
412+ globalPosition : _initialPosition.global ,
413+ localPosition : _initialPosition.local ,
414+ kind : getKindForPointer (pointer),
415+ );
412416 invokeCallback <void >('onStart' , () => onStart !(details));
417+ }
413418 }
414419
415420 void _checkUpdate ({
@@ -420,15 +425,16 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
420425 Offset ? localPosition,
421426 }) {
422427 assert (_initialButtons == kPrimaryButton);
423- final DragUpdateDetails details = DragUpdateDetails (
424- sourceTimeStamp : sourceTimeStamp,
425- delta : delta ,
426- primaryDelta : primaryDelta ,
427- globalPosition : globalPosition ,
428- localPosition : localPosition ,
429- );
430- if (onUpdate != null )
428+ if (onUpdate != null ) {
429+ final DragUpdateDetails details = DragUpdateDetails (
430+ sourceTimeStamp : sourceTimeStamp ,
431+ delta : delta ,
432+ primaryDelta : primaryDelta ,
433+ globalPosition : globalPosition ,
434+ localPosition : localPosition,
435+ );
431436 invokeCallback <void >('onUpdate' , () => onUpdate !(details));
437+ }
432438 }
433439
434440 void _checkEnd (int pointer) {
0 commit comments