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
e74c15ca
Unverified
Commit
e74c15ca
authored
May 07, 2021
by
Kate Lovett
Committed by
GitHub
May 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate `GestureDetector.kind` in favor of new `supportedDevices` (#81858)
parent
8694e19a
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
867 additions
and
64 deletions
+867
-64
fix_data.yaml
packages/flutter/lib/fix_data.yaml
+408
-0
eager.dart
packages/flutter/lib/src/gestures/eager.dart
+9
-2
force_press.dart
packages/flutter/lib/src/gestures/force_press.dart
+11
-2
long_press.dart
packages/flutter/lib/src/gestures/long_press.dart
+13
-5
monodrag.dart
packages/flutter/lib/src/gestures/monodrag.dart
+33
-21
multidrag.dart
packages/flutter/lib/src/gestures/multidrag.dart
+60
-5
multitap.dart
packages/flutter/lib/src/gestures/multitap.dart
+23
-3
recognizer.dart
packages/flutter/lib/src/gestures/recognizer.dart
+41
-12
scale.dart
packages/flutter/lib/src/gestures/scale.dart
+11
-2
platform_view.dart
packages/flutter/lib/src/rendering/platform_view.dart
+4
-4
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+4
-6
scrollbar.dart
packages/flutter/lib/src/widgets/scrollbar.dart
+2
-2
force_press_test.dart
packages/flutter/test/gestures/force_press_test.dart
+15
-0
long_press_test.dart
packages/flutter/test/gestures/long_press_test.dart
+15
-0
monodrag_test.dart
packages/flutter/test/gestures/monodrag_test.dart
+30
-0
multidrag_test.dart
packages/flutter/test/gestures/multidrag_test.dart
+57
-0
multitap_test.dart
packages/flutter/test/gestures/multitap_test.dart
+30
-0
recognizer_test.dart
packages/flutter/test/gestures/recognizer_test.dart
+14
-0
scale_test.dart
packages/flutter/test/gestures/scale_test.dart
+15
-0
gestures.dart
packages/flutter/test_fixes/gestures.dart
+36
-0
gestures.dart.expect
packages/flutter/test_fixes/gestures.dart.expect
+36
-0
No files found.
packages/flutter/lib/fix_data.yaml
View file @
e74c15ca
...
...
@@ -15,6 +15,414 @@
version
:
1
transforms
:
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
ScaleGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
MultiTapGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
4
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
DoubleTapGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
DelayedMultiDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
4
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
VerticalMultiDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
HorizontalMultiDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
ImmediateMultiDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
MultiDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
LongPressGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
4
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
ForcePressGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
6
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
EagerGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
2
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
PrimaryPointerGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
6
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
OneSequenceGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
GestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
HorizontalDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
VerticalDragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
3
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/81858
-
title
:
"
Migrate
to
'supportedDevices'"
date
:
2021-05-04
element
:
uris
:
[
'
gestures.dart'
]
constructor
:
'
'
inClass
:
'
DragGestureRecognizer'
oneOf
:
-
if
:
"
kind
!=
''"
changes
:
-
kind
:
'
addParameter'
index
:
5
name
:
'
supportedDevices'
style
:
optional_named
argumentValue
:
expression
:
'
<PointerDeviceKind>{{%
kind
%}}'
requiredIf
:
"
kind
!=
''"
-
kind
:
'
removeParameter'
name
:
'
kind'
variables
:
kind
:
kind
:
'
fragment'
value
:
'
arguments[kind]'
# Changes made in https://github.com/flutter/flutter/pull/79160
-
title
:
"
Migrate
to
'dragAnchorStrategy'"
date
:
2021-04-05
...
...
packages/flutter/lib/src/gestures/eager.dart
View file @
e74c15ca
...
...
@@ -15,8 +15,15 @@ import 'recognizer.dart';
class
EagerGestureRecognizer
extends
OneSequenceGestureRecognizer
{
/// Create an eager gesture recognizer.
///
/// {@macro flutter.gestures.GestureRecognizer.kind}
EagerGestureRecognizer
({
PointerDeviceKind
?
kind
})
:
super
(
kind:
kind
);
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
EagerGestureRecognizer
({
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
kind:
kind
,
supportedDevices:
supportedDevices
);
@override
void
addAllowedPointer
(
PointerDownEvent
event
)
{
...
...
packages/flutter/lib/src/gestures/force_press.dart
View file @
e74c15ca
...
...
@@ -116,18 +116,27 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
/// to 1.0 for values of `pressure` that are between `pressureMin` and
/// `pressureMax`.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
ForcePressGestureRecognizer
({
this
.
startPressure
=
0.4
,
this
.
peakPressure
=
0.85
,
this
.
interpolation
=
_inverseLerp
,
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
assert
(
startPressure
!=
null
),
assert
(
peakPressure
!=
null
),
assert
(
interpolation
!=
null
),
assert
(
peakPressure
>
startPressure
),
super
(
debugOwner:
debugOwner
,
kind:
kind
);
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// A pointer is in contact with the screen and has just pressed with a force
/// exceeding the [startPressure]. Consequently, if there were other gesture
...
...
packages/flutter/lib/src/gestures/long_press.dart
View file @
e74c15ca
...
...
@@ -242,17 +242,25 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
///
/// The [duration] argument can be used to overwrite the default duration
/// after which the long press will be recognized.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
LongPressGestureRecognizer
({
Duration
?
duration
,
double
?
postAcceptSlopTolerance
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
Object
?
debugOwner
,
})
:
super
(
deadline:
duration
??
kLongPressTimeout
,
postAcceptSlopTolerance:
postAcceptSlopTolerance
,
kind:
kind
,
debugOwner:
debugOwner
,
);
deadline:
duration
??
kLongPressTimeout
,
postAcceptSlopTolerance:
postAcceptSlopTolerance
,
kind:
kind
,
supportedDevices:
supportedDevices
,
debugOwner:
debugOwner
,
);
bool
_longPressAccepted
=
false
;
OffsetPair
?
_longPressOrigin
;
...
...
packages/flutter/lib/src/gestures/monodrag.dart
View file @
e74c15ca
...
...
@@ -63,15 +63,23 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
///
/// [dragStartBehavior] must not be null.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
DragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
this
.
dragStartBehavior
=
DragStartBehavior
.
start
,
this
.
velocityTrackerBuilder
=
_defaultBuilder
,
this
.
supportedDevices
=
_kAllPointerDeviceKinds
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
assert
(
dragStartBehavior
!=
null
),
super
(
debugOwner:
debugOwner
,
kind:
kind
);
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
static
VelocityTracker
_defaultBuilder
(
PointerEvent
event
)
=>
VelocityTracker
.
withKind
(
event
.
kind
);
/// Configure the behavior of offsets sent to [onStart].
...
...
@@ -201,11 +209,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
/// match the native behavior on that platform.
GestureVelocityTrackerBuilder
velocityTrackerBuilder
;
/// The device types that this gesture recognizer will accept drags from.
///
/// If not specified, defaults to all pointer kinds.
Set
<
PointerDeviceKind
>
supportedDevices
;
_DragState
_state
=
_DragState
.
ready
;
late
OffsetPair
_initialPosition
;
late
OffsetPair
_pendingDragOffset
;
...
...
@@ -236,9 +239,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
@override
bool
isPointerAllowed
(
PointerEvent
event
)
{
if
(!
supportedDevices
.
contains
(
event
.
kind
))
{
return
false
;
}
if
(
_initialButtons
==
null
)
{
switch
(
event
.
buttons
)
{
case
kPrimaryButton:
...
...
@@ -513,12 +513,20 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
class
VerticalDragGestureRecognizer
extends
DragGestureRecognizer
{
/// Create a gesture recognizer for interactions in the vertical axis.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
VerticalDragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>
supportedDevices
=
_kAllPointerDeviceKinds
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
@override
bool
isFlingGesture
(
VelocityEstimate
estimate
,
PointerDeviceKind
kind
)
{
...
...
@@ -542,10 +550,6 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer {
String
get
debugDescription
=>
'vertical drag'
;
}
const
Set
<
PointerDeviceKind
>
_kAllPointerDeviceKinds
=
<
PointerDeviceKind
>{
...
PointerDeviceKind
.
values
,
};
/// Recognizes movement in the horizontal direction.
///
/// Used for horizontal scrolling.
...
...
@@ -559,12 +563,20 @@ const Set<PointerDeviceKind> _kAllPointerDeviceKinds = <PointerDeviceKind>{
class
HorizontalDragGestureRecognizer
extends
DragGestureRecognizer
{
/// Create a gesture recognizer for interactions in the horizontal axis.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
HorizontalDragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>
supportedDevices
=
_kAllPointerDeviceKinds
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
@override
bool
isFlingGesture
(
VelocityEstimate
estimate
,
PointerDeviceKind
kind
)
{
...
...
packages/flutter/lib/src/gestures/multidrag.dart
View file @
e74c15ca
...
...
@@ -199,10 +199,21 @@ abstract class MultiDragPointerState {
/// start after a long-press gesture.
abstract
class
MultiDragGestureRecognizer
<
T
extends
MultiDragPointerState
>
extends
GestureRecognizer
{
/// Initialize the object.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
MultiDragGestureRecognizer
({
required
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// Called when this class recognizes the start of a drag gesture.
///
...
...
@@ -348,10 +359,21 @@ class _ImmediatePointerState extends MultiDragPointerState {
/// start after a long-press gesture.
class
ImmediateMultiDragGestureRecognizer
extends
MultiDragGestureRecognizer
<
_ImmediatePointerState
>
{
/// Create a gesture recognizer for tracking multiple pointers at once.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
ImmediateMultiDragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
@override
_ImmediatePointerState
createNewPointerState
(
PointerDownEvent
event
)
{
...
...
@@ -397,10 +419,21 @@ class _HorizontalPointerState extends MultiDragPointerState {
class
HorizontalMultiDragGestureRecognizer
extends
MultiDragGestureRecognizer
<
_HorizontalPointerState
>
{
/// Create a gesture recognizer for tracking multiple pointers at once
/// but only if they first move horizontally.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
HorizontalMultiDragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
@override
_HorizontalPointerState
createNewPointerState
(
PointerDownEvent
event
)
{
...
...
@@ -446,10 +479,21 @@ class _VerticalPointerState extends MultiDragPointerState {
class
VerticalMultiDragGestureRecognizer
extends
MultiDragGestureRecognizer
<
_VerticalPointerState
>
{
/// Create a gesture recognizer for tracking multiple pointers at once
/// but only if they first move vertically.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
VerticalMultiDragGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
@override
_VerticalPointerState
createNewPointerState
(
PointerDownEvent
event
)
{
...
...
@@ -548,12 +592,23 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela
/// remain in the same place for [delay] (up to [kTouchSlop]). The [delay]
/// defaults to [kLongPressTimeout] to match [LongPressGestureRecognizer] but
/// can be changed for specific behaviors.
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
DelayedMultiDragGestureRecognizer
({
this
.
delay
=
kLongPressTimeout
,
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
assert
(
delay
!=
null
),
super
(
debugOwner:
debugOwner
,
kind:
kind
);
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// The amount of time the pointer must remain in the same place for the drag
/// to be recognized.
...
...
packages/flutter/lib/src/gestures/multitap.dart
View file @
e74c15ca
...
...
@@ -113,11 +113,20 @@ class _TapTracker {
class
DoubleTapGestureRecognizer
extends
GestureRecognizer
{
/// Create a gesture recognizer for double taps.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
DoubleTapGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
// Implementation notes:
//
...
...
@@ -456,11 +465,22 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
///
/// The [longTapDelay] defaults to [Duration.zero], which means
/// [onLongTapDown] is called immediately after [onTapDown].
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
MultiTapGestureRecognizer
({
this
.
longTapDelay
=
Duration
.
zero
,
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// A pointer that might cause a tap has contacted the screen at a particular
/// location.
...
...
packages/flutter/lib/src/gestures/recognizer.dart
View file @
e74c15ca
...
...
@@ -61,12 +61,21 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
/// The argument is optional and is only used for debug purposes (e.g. in the
/// [toString] serialization).
///
/// {@template flutter.gestures.GestureRecognizer.
kind
}
/// It's possible to limit this recognizer to a specific
[PointerDeviceKind]
/// by providing the optional [
kind] argument. If [kind
] is null,
/// {@template flutter.gestures.GestureRecognizer.
supportedDevices
}
/// It's possible to limit this recognizer to a specific
set of [PointerDeviceKind]s
/// by providing the optional [
supportedDevices] argument. If [supportedDevices
] is null,
/// the recognizer will accept pointer events from all device kinds.
/// {@endtemplate}
GestureRecognizer
({
this
.
debugOwner
,
PointerDeviceKind
?
kind
})
:
_kindFilter
=
kind
;
GestureRecognizer
({
this
.
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
assert
(
kind
==
null
||
supportedDevices
==
null
),
_supportedDevices
=
kind
==
null
?
supportedDevices
:
<
PointerDeviceKind
>{
kind
};
/// The recognizer's owner.
///
...
...
@@ -74,9 +83,11 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
/// this gesture recognizer was created, to aid in debugging.
final
Object
?
debugOwner
;
/// The kind of device that's allowed to be recognized. If null, events from
/// all device kinds will be tracked and recognized.
final
PointerDeviceKind
?
_kindFilter
;
/// The kind of devices that are allowed to be recognized as provided by
/// `supportedDevices` in the constructor, or the currently deprecated `kind`.
/// These cannot both be set. If both are null, events from all device kinds will be
/// tracked and recognized.
final
Set
<
PointerDeviceKind
>?
_supportedDevices
;
/// Holds a mapping between pointer IDs and the kind of devices they are
/// coming from.
...
...
@@ -130,7 +141,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
bool
isPointerAllowed
(
PointerDownEvent
event
)
{
// Currently, it only checks for device kind. But in the future we could check
// for other things e.g. mouse button.
return
_
kindFilter
==
null
||
_kindFilter
==
event
.
kind
;
return
_
supportedDevices
==
null
||
_supportedDevices
!.
contains
(
event
.
kind
)
;
}
/// For a given pointer ID, returns the device kind associated with it.
...
...
@@ -220,11 +231,20 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
abstract
class
OneSequenceGestureRecognizer
extends
GestureRecognizer
{
/// Initialize the object.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
OneSequenceGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
);
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
final
Map
<
int
,
GestureArenaEntry
>
_entries
=
<
int
,
GestureArenaEntry
>{};
final
Set
<
int
>
_trackedPointers
=
HashSet
<
int
>();
...
...
@@ -393,13 +413,18 @@ enum GestureRecognizerState {
abstract
class
PrimaryPointerGestureRecognizer
extends
OneSequenceGestureRecognizer
{
/// Initializes the [deadline] field during construction of subclasses.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
PrimaryPointerGestureRecognizer
({
this
.
deadline
,
this
.
preAcceptSlopTolerance
=
kTouchSlop
,
this
.
postAcceptSlopTolerance
=
kTouchSlop
,
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
assert
(
preAcceptSlopTolerance
==
null
||
preAcceptSlopTolerance
>=
0
,
'The preAcceptSlopTolerance must be positive or null'
,
...
...
@@ -408,7 +433,11 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
postAcceptSlopTolerance
==
null
||
postAcceptSlopTolerance
>=
0
,
'The postAcceptSlopTolerance must be positive or null'
,
),
super
(
debugOwner:
debugOwner
,
kind:
kind
);
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// If non-null, the recognizer will call [didExceedDeadline] after this
/// amount of time has elapsed since starting to track the primary pointer.
...
...
packages/flutter/lib/src/gestures/scale.dart
View file @
e74c15ca
...
...
@@ -247,13 +247,22 @@ class _LineBetweenPointers{
class
ScaleGestureRecognizer
extends
OneSequenceGestureRecognizer
{
/// Create a gesture recognizer for interactions intended for scaling content.
///
/// {@macro flutter.gestures.GestureRecognizer.
kind
}
/// {@macro flutter.gestures.GestureRecognizer.
supportedDevices
}
ScaleGestureRecognizer
({
Object
?
debugOwner
,
@Deprecated
(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.'
,
)
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
this
.
dragStartBehavior
=
DragStartBehavior
.
down
,
})
:
assert
(
dragStartBehavior
!=
null
),
super
(
debugOwner:
debugOwner
,
kind:
kind
);
super
(
debugOwner:
debugOwner
,
kind:
kind
,
supportedDevices:
supportedDevices
,
);
/// Determines what point is used as the starting point in all calculations
/// involving this gesture.
...
...
packages/flutter/lib/src/rendering/platform_view.dart
View file @
e74c15ca
...
...
@@ -422,8 +422,8 @@ class _UiKitViewGestureRecognizer extends OneSequenceGestureRecognizer {
_UiKitViewGestureRecognizer
(
this
.
controller
,
this
.
gestureRecognizerFactories
,
{
PointerDeviceKind
?
kind
,
})
:
super
(
kind:
kind
)
{
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
supportedDevices:
supportedDevices
)
{
team
=
GestureArenaTeam
()
..
captain
=
this
;
_gestureRecognizers
=
gestureRecognizerFactories
.
map
(
...
...
@@ -500,8 +500,8 @@ class _PlatformViewGestureRecognizer extends OneSequenceGestureRecognizer {
_PlatformViewGestureRecognizer
(
_HandlePointerEvent
handlePointerEvent
,
this
.
gestureRecognizerFactories
,
{
PointerDeviceKind
?
kind
,
})
:
super
(
kind:
kind
)
{
Set
<
PointerDeviceKind
>?
supportedDevices
,
})
:
super
(
supportedDevices:
supportedDevices
)
{
team
=
GestureArenaTeam
()
..
captain
=
this
;
_gestureRecognizers
=
gestureRecognizerFactories
.
map
(
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
e74c15ca
...
...
@@ -553,7 +553,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
case
Axis
.
vertical
:
_gestureRecognizers
=
<
Type
,
GestureRecognizerFactory
>{
VerticalDragGestureRecognizer:
GestureRecognizerFactoryWithHandlers
<
VerticalDragGestureRecognizer
>(
()
=>
VerticalDragGestureRecognizer
(),
()
=>
VerticalDragGestureRecognizer
(
supportedDevices:
_configuration
.
dragDevices
),
(
VerticalDragGestureRecognizer
instance
)
{
instance
..
onDown
=
_handleDragDown
...
...
@@ -565,8 +565,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
..
velocityTrackerBuilder
=
_configuration
.
velocityTrackerBuilder
(
context
)
..
dragStartBehavior
=
widget
.
dragStartBehavior
..
supportedDevices
=
_configuration
.
dragDevices
;
..
dragStartBehavior
=
widget
.
dragStartBehavior
;
},
),
};
...
...
@@ -574,7 +573,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
case
Axis
.
horizontal
:
_gestureRecognizers
=
<
Type
,
GestureRecognizerFactory
>{
HorizontalDragGestureRecognizer:
GestureRecognizerFactoryWithHandlers
<
HorizontalDragGestureRecognizer
>(
()
=>
HorizontalDragGestureRecognizer
(),
()
=>
HorizontalDragGestureRecognizer
(
supportedDevices:
_configuration
.
dragDevices
),
(
HorizontalDragGestureRecognizer
instance
)
{
instance
..
onDown
=
_handleDragDown
...
...
@@ -586,8 +585,7 @@ class ScrollableState extends State<Scrollable> with TickerProviderStateMixin, R
..
minFlingVelocity
=
_physics
?.
minFlingVelocity
..
maxFlingVelocity
=
_physics
?.
maxFlingVelocity
..
velocityTrackerBuilder
=
_configuration
.
velocityTrackerBuilder
(
context
)
..
dragStartBehavior
=
widget
.
dragStartBehavior
..
supportedDevices
=
_configuration
.
dragDevices
;
..
dragStartBehavior
=
widget
.
dragStartBehavior
;
},
),
};
...
...
packages/flutter/lib/src/widgets/scrollbar.dart
View file @
e74c15ca
...
...
@@ -1383,14 +1383,14 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv
class
_ThumbPressGestureRecognizer
extends
LongPressGestureRecognizer
{
_ThumbPressGestureRecognizer
({
double
?
postAcceptSlopTolerance
,
PointerDeviceKind
?
kind
,
Set
<
PointerDeviceKind
>?
supportedDevices
,
required
Object
debugOwner
,
required
GlobalKey
customPaintKey
,
required
Duration
pressDuration
,
})
:
_customPaintKey
=
customPaintKey
,
super
(
postAcceptSlopTolerance:
postAcceptSlopTolerance
,
kind:
kind
,
supportedDevices:
supportedDevices
,
debugOwner:
debugOwner
,
duration:
pressDuration
,
);
...
...
packages/flutter/test/gestures/force_press_test.dart
View file @
e74c15ca
...
...
@@ -606,4 +606,19 @@ void main() {
expect
(
updated
,
1
);
expect
(
ended
,
1
);
});
testWidgets
(
'ForecePressGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
ForcePressGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test/gestures/long_press_test.dart
View file @
e74c15ca
...
...
@@ -714,4 +714,19 @@ void main() {
longPress
.
dispose
();
recognized
.
clear
();
});
testWidgets
(
'LongPressGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
LongPressGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test/gestures/monodrag_test.dart
View file @
e74c15ca
...
...
@@ -48,6 +48,36 @@ void main() {
GestureBinding
.
instance
!.
handleEvent
(
up90
,
HitTestEntry
(
MockHitTestTarget
()));
GestureBinding
.
instance
!.
handleEvent
(
up91
,
HitTestEntry
(
MockHitTestTarget
()));
});
testWidgets
(
'VerticalDragGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
VerticalDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
testWidgets
(
'HorizontalDragGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
HorizontalDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
class
MockHitTestTarget
implements
HitTestTarget
{
...
...
packages/flutter/test/gestures/multidrag_test.dart
View file @
e74c15ca
...
...
@@ -89,4 +89,61 @@ void main() {
expect
(
didStartDrag
,
isFalse
);
drag
.
dispose
();
});
testWidgets
(
'ImmediateMultiGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
try
{
ImmediateMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
}
catch
(
error
)
{
expect
(
error
,
isAssertionError
);
expect
(
error
.
toString
(),
contains
(
'kind == null || supportedDevices == null'
));
}
});
testWidgets
(
'HorizontalMultiDragGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
HorizontalMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
testWidgets
(
'VerticalMultiDragGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
VerticalMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
testWidgets
(
'DelayedMultiDragGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
DelayedMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test/gestures/multitap_test.dart
View file @
e74c15ca
...
...
@@ -146,4 +146,34 @@ void main() {
tap
.
dispose
();
});
testWidgets
(
'DoubleTapGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
DoubleTapGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
testWidgets
(
'MultiTapGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
MultiTapGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test/gestures/recognizer_test.dart
View file @
e74c15ca
...
...
@@ -48,6 +48,20 @@ void main() {
final
OffsetPair
difference
=
offset2
-
offset1
;
expect
(
difference
.
local
,
const
Offset
(
40
,
40
));
expect
(
difference
.
global
,
const
Offset
(
40
,
40
));
});
testWidgets
(
'EagerGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
EagerGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test/gestures/scale_test.dart
View file @
e74c15ca
...
...
@@ -651,4 +651,19 @@ void main() {
scale
.
dispose
();
});
testWidgets
(
'ScaleGestureRecognizer asserts when kind and supportedDevices are both set'
,
(
WidgetTester
tester
)
async
{
expect
(
()
{
ScaleGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
,
supportedDevices:
<
PointerDeviceKind
>{
PointerDeviceKind
.
touch
},
);
},
throwsA
(
isA
<
AssertionError
>().
having
((
AssertionError
error
)
=>
error
.
toString
(),
'description'
,
contains
(
'kind == null || supportedDevices == null'
)),
),
);
});
}
packages/flutter/test_fixes/gestures.dart
View file @
e74c15ca
...
...
@@ -14,4 +14,40 @@ void main() {
// Changes made in https://github.com/flutter/flutter/pull/66043
VelocityTracker
tracker
=
VelocityTracker
();
tracker
=
VelocityTracker
(
PointerDeviceKind
.
mouse
);
// Changes made in https://github.com/flutter/flutter/pull/81858
DragGestureRecognizer
();
DragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
VerticalDragGestureRecognizer
();
VerticalDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
HorizontalDragGestureRecognizer
();
HorizontalDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
GestureRecognizer
();
GestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
OneSequenceGestureRecognizer
();
OneSequenceGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
PrimaryPointerGestureRecognizer
();
PrimaryPointerGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
EagerGestureRecognizer
();
EagerGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
ForcePressGestureRecognizer
();
ForcePressGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
LongPressGestureRecognizer
();
LongPressGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
MultiDragGestureRecognizer
();
MultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
ImmediateMultiDragGestureRecognizer
();
ImmediateMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
HorizontalMultiDragGestureRecognizer
();
HorizontalMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
VerticalMultiDragGestureRecognizer
();
VerticalMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
DelayedMultiDragGestureRecognizer
();
DelayedMultiDragGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
DoubleTapGestureRecognizer
();
DoubleTapGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
MultiTapGestureRecognizer
();
MultiTapGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
ScaleGestureRecognizer
();
ScaleGestureRecognizer
(
kind:
PointerDeviceKind
.
touch
);
}
packages/flutter/test_fixes/gestures.dart.expect
View file @
e74c15ca
...
...
@@ -14,4 +14,40 @@ void main() {
// Changes made in https://github.com/flutter/flutter/pull/66043
VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
tracker = VelocityTracker.withKind(PointerDeviceKind.mouse);
// Changes made in https://github.com/flutter/flutter/pull/81858
DragGestureRecognizer();
DragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
VerticalDragGestureRecognizer();
VerticalDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
HorizontalDragGestureRecognizer();
HorizontalDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
GestureRecognizer();
GestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
OneSequenceGestureRecognizer();
OneSequenceGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
PrimaryPointerGestureRecognizer();
PrimaryPointerGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
EagerGestureRecognizer();
EagerGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
ForcePressGestureRecognizer();
ForcePressGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
LongPressGestureRecognizer();
LongPressGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
MultiDragGestureRecognizer();
MultiDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
ImmediateMultiDragGestureRecognizer();
ImmediateMultiDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
HorizontalMultiDragGestureRecognizer();
HorizontalMultiDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
VerticalMultiDragGestureRecognizer();
VerticalMultiDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
DelayedMultiDragGestureRecognizer();
DelayedMultiDragGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
DoubleTapGestureRecognizer();
DoubleTapGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
MultiTapGestureRecognizer();
MultiTapGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
ScaleGestureRecognizer();
ScaleGestureRecognizer(supportedDevices: <PointerDeviceKind>{PointerDeviceKind.touch});
}
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