Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
4c170964
Unverified
Commit
4c170964
authored
May 19, 2021
by
Tong Mu
Committed by
GitHub
May 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drag gesture recognizer accepts all pointers when any pointer is accepted (#82786)
parent
8f536ec1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+4
-0
drag_test.dart
packages/flutter/test/gestures/drag_test.dart
+44
-0
No files found.
packages/flutter/lib/src/gestures/monodrag.dart
View file @
4c170964
...
...
@@ -365,6 +365,10 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
localPosition:
correctedPosition
.
local
,
);
}
// This acceptGesture might have been called only for one pointer, instead
// of all pointers. Resolve all pointers to `accepted`. This won't cause
// infinite recursion because an accepted pointer won't be accepted again.
resolve
(
GestureDisposition
.
accepted
);
}
}
...
...
packages/flutter/test/gestures/drag_test.dart
View file @
4c170964
...
...
@@ -1440,4 +1440,48 @@ void main() {
logs
.
clear
();
},
);
testGesture
(
'Does not crash when one of the 2 pointers wins by default and is then released'
,
(
GestureTester
tester
)
{
// Regression test for https://github.com/flutter/flutter/issues/82784
bool
didStartDrag
=
false
;
final
HorizontalDragGestureRecognizer
drag
=
HorizontalDragGestureRecognizer
()
..
onStart
=
(
_
)
{
didStartDrag
=
true
;
}
..
onEnd
=
(
DragEndDetails
details
)
{}
// Crash triggers at onEnd.
..
dragStartBehavior
=
DragStartBehavior
.
down
;
final
TapGestureRecognizer
tap
=
TapGestureRecognizer
()..
onTap
=
()
{};
final
TapGestureRecognizer
tap2
=
TapGestureRecognizer
()..
onTap
=
()
{};
// The pointer1 is caught by drag and tap.
final
TestPointer
pointer1
=
TestPointer
(
5
);
final
PointerDownEvent
down1
=
pointer1
.
down
(
const
Offset
(
10.0
,
10.0
));
drag
.
addPointer
(
down1
);
tap
.
addPointer
(
down1
);
tester
.
closeArena
(
pointer1
.
pointer
);
tester
.
route
(
down1
);
// The pointer2 is caught by drag and tap2.
final
TestPointer
pointer2
=
TestPointer
(
6
);
final
PointerDownEvent
down2
=
pointer2
.
down
(
const
Offset
(
10.0
,
10.0
));
drag
.
addPointer
(
down2
);
tap2
.
addPointer
(
down2
);
tester
.
closeArena
(
pointer2
.
pointer
);
tester
.
route
(
down2
);
// The tap is disposed, leaving drag the default winner.
tap
.
dispose
();
// Wait for microtasks to finish, during which drag claims victory.
tester
.
async
.
flushMicrotasks
();
expect
(
didStartDrag
,
true
);
// The pointer1 is released, leaving pointer2 drag's only pointer.
tester
.
route
(
pointer1
.
up
());
drag
.
dispose
();
// Passes if no crashes here.
tap2
.
dispose
();
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment