Add "OneSequenceRecognizer.resolvePointer". Fix DragGestureRecognizer crash on multiple pointers#39017
Merged
dkwingsmt merged 18 commits intoflutter:masterfrom Aug 27, 2019
Merged
Conversation
This TODO was added because https://github.com/flutter/flutter/pull/26734/files#diff-9a8096bf3325041c65696e0995352c5dL167 removed 2 tests, which have been added back.
Contributor
Author
|
This should also have fixed #36350 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
This PR fixes some edge cases when
DragGestureRecognizerinteracts with multiple pointers.It also changes
drag_test.dartso that allGestureRecognizer.disposecalls are guarded byaddTearDown.New method
resolvePointerTo fix this, a new API
OneSequenceRecognizer.resolvePointeris introduced. Here is why this new API is necessary:Currently
OneSequenceRecognizerprovides the following ways to control arena entries:startTrackingPointer(pointer)adds one pointer to the arena.resolve(GestureDisposition.rejected)removes all pointers from the arena.In other words, there is no way to remove one pointer from the arena.
But it is needed for
DragGestureRecognizer. Consider the following scenario:Expect: If pointer 2 goes up, the drag is canceled. If pointer 2 moves away, the drag is accepted.
This can not be done with the current tools:
I've also considered embedding this functionality into other methods, mostly
stopTrackingPoitner. The problem is gestures that stop tracking pointer do not always want to give up the arena. For example,TapGestureRecognizerstops tracking when the pointer is no longer down, but it does not declare either victory or defeat of the arena, instead waits until itself to be the last member and wins via sweeping.As a conclusion, we need a new API that can resolve a single pointer. Theoretically we only need to resolve to rejection in this case, but there is no reason not to provide both rejection and acceptance.
Related Issues
Tests
I added the following tests:
On multiple pointers:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?