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
ad20d368
Commit
ad20d368
authored
Dec 06, 2019
by
Tong Mu
Committed by
Flutter GitHub Bot
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix null event crash in TapGestureRecognizer (#45943)
parent
a2005eaf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletion
+52
-1
recognizer.dart
packages/flutter/lib/src/gestures/recognizer.dart
+7
-1
tap_test.dart
packages/flutter/test/gestures/tap_test.dart
+45
-0
No files found.
packages/flutter/lib/src/gestures/recognizer.dart
View file @
ad20d368
...
...
@@ -398,6 +398,9 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
/// If non-null, the recognizer will call [didExceedDeadline] after this
/// amount of time has elapsed since starting to track the primary pointer.
///
/// The [didExceedDeadline] will not be called if the primary pointer is
/// accepted, rejected, or all pointers are up or canceled before [deadline].
final
Duration
deadline
;
/// The maximum distance in logical pixels the gesture is allowed to drift
...
...
@@ -495,7 +498,10 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
@override
void
acceptGesture
(
int
pointer
)
{
_gestureAccepted
=
true
;
if
(
pointer
==
primaryPointer
)
{
_stopTimer
();
_gestureAccepted
=
true
;
}
}
@override
...
...
packages/flutter/test/gestures/tap_test.dart
View file @
ad20d368
...
...
@@ -582,6 +582,51 @@ void main() {
drag
.
dispose
();
});
testGesture
(
'non-primary pointers does not trigger timeout'
,
(
GestureTester
tester
)
{
// Regression test for https://github.com/flutter/flutter/issues/43310
// Pointer1 down, pointer2 down, then pointer 1 up, all within the timeout.
// In this way, `BaseTapGestureRecognizer.didExceedDeadline` can be triggered
// after its `_reset`.
final
TapGestureRecognizer
tap
=
TapGestureRecognizer
();
final
List
<
String
>
recognized
=
<
String
>[];
tap
.
onTapDown
=
(
_
)
{
recognized
.
add
(
'down'
);
};
tap
.
onTapUp
=
(
_
)
{
recognized
.
add
(
'up'
);
};
tap
.
onTap
=
()
{
recognized
.
add
(
'tap'
);
};
tap
.
onTapCancel
=
()
{
recognized
.
add
(
'cancel'
);
};
tap
.
addPointer
(
down1
);
tester
.
closeArena
(
down1
.
pointer
);
tap
.
addPointer
(
down2
);
tester
.
closeArena
(
down2
.
pointer
);
expect
(
recognized
,
isEmpty
);
tester
.
route
(
up1
);
GestureBinding
.
instance
.
gestureArena
.
sweep
(
down1
.
pointer
);
expect
(
recognized
,
<
String
>[
'down'
,
'up'
,
'tap'
]);
recognized
.
clear
();
// If regression happens, the following step will throw error
tester
.
async
.
elapse
(
const
Duration
(
milliseconds:
200
));
expect
(
recognized
,
isEmpty
);
tester
.
route
(
up2
);
GestureBinding
.
instance
.
gestureArena
.
sweep
(
down2
.
pointer
);
expect
(
recognized
,
isEmpty
);
tap
.
dispose
();
});
group
(
'Enforce consistent-button restriction:'
,
()
{
// Change buttons during down-up sequence 1
const
PointerMoveEvent
move1lr
=
PointerMoveEvent
(
...
...
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