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
4bdea117
Unverified
Commit
4bdea117
authored
Jan 22, 2021
by
xubaolin
Committed by
GitHub
Jan 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a tap gesture exception (#73846)
parent
0a668b98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
tap.dart
packages/flutter/lib/src/gestures/tap.dart
+9
-0
double_tap_test.dart
packages/flutter/test/gestures/double_tap_test.dart
+35
-0
No files found.
packages/flutter/lib/src/gestures/tap.dart
View file @
4bdea117
...
...
@@ -191,6 +191,14 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
void
addAllowedPointer
(
PointerDownEvent
event
)
{
assert
(
event
!=
null
);
if
(
state
==
GestureRecognizerState
.
ready
)
{
// If there is no result in the previous gesture arena,
// we ignore them and prepare to accept a new pointer.
if
(
_down
!=
null
&&
_up
!=
null
)
{
assert
(
_down
!.
pointer
==
_up
!.
pointer
);
_reset
();
}
assert
(
_down
==
null
&&
_up
==
null
);
// `_down` must be assigned in this method instead of `handlePrimaryPointer`,
// because `acceptGesture` might be called before `handlePrimaryPointer`,
// which relies on `_down` to call `handleTapDown`.
...
...
@@ -284,6 +292,7 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
if
(!
_wonArenaForPrimaryPointer
||
_up
==
null
)
{
return
;
}
assert
(
_up
!.
pointer
==
_down
!.
pointer
);
handleTapUp
(
down:
_down
!,
up:
_up
!);
_reset
();
}
...
...
packages/flutter/test/gestures/double_tap_test.dart
View file @
4bdea117
...
...
@@ -622,4 +622,39 @@ void main() {
recognized
.
clear
();
doubleTap
.
dispose
();
});
// Regression test for https://github.com/flutter/flutter/issues/73667
testGesture
(
'Unfinished DoubleTap does not prevent competing Tap'
,
(
GestureTester
tester
)
{
int
tapCount
=
0
;
final
DoubleTapGestureRecognizer
doubleTap
=
DoubleTapGestureRecognizer
()
..
onDoubleTap
=
()
{};
final
TapGestureRecognizer
tap
=
TapGestureRecognizer
()
..
onTap
=
()
=>
tapCount
++;
// Open a arena with 2 members and holding.
doubleTap
.
addPointer
(
down1
);
tap
.
addPointer
(
down1
);
tester
.
closeArena
(
1
);
tester
.
route
(
down1
);
tester
.
route
(
up1
);
GestureBinding
.
instance
!.
gestureArena
.
sweep
(
1
);
// Open a new arena with only one TapGestureRecognizer.
tester
.
async
.
elapse
(
const
Duration
(
milliseconds:
100
));
tap
.
addPointer
(
down2
);
tester
.
closeArena
(
2
);
tester
.
route
(
down2
);
final
PointerMoveEvent
move2
=
PointerMoveEvent
(
pointer:
2
,
position:
down2
.
position
);
tester
.
route
(
move2
);
tester
.
route
(
up2
);
expect
(
tapCount
,
1
);
// The second tap will win immediately.
GestureBinding
.
instance
!.
gestureArena
.
sweep
(
2
);
// Finish the previous gesture arena.
tester
.
async
.
elapse
(
const
Duration
(
milliseconds:
300
));
expect
(
tapCount
,
1
);
// The first tap should not trigger onTap callback though it wins the arena.
tap
.
dispose
();
doubleTap
.
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