diff --git a/packages/flutter/lib/fix_data.yaml b/packages/flutter/lib/fix_data.yaml index 4f6119de15..45420f379e 100644 --- a/packages/flutter/lib/fix_data.yaml +++ b/packages/flutter/lib/fix_data.yaml @@ -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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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: '{{% 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 diff --git a/packages/flutter/lib/src/gestures/eager.dart b/packages/flutter/lib/src/gestures/eager.dart index 5440f9b0e7..9f1dc02c87 100644 --- a/packages/flutter/lib/src/gestures/eager.dart +++ b/packages/flutter/lib/src/gestures/eager.dart @@ -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? supportedDevices, + }) : super(kind: kind, supportedDevices: supportedDevices); @override void addAllowedPointer(PointerDownEvent event) { diff --git a/packages/flutter/lib/src/gestures/force_press.dart b/packages/flutter/lib/src/gestures/force_press.dart index 38160ee5e1..4da8cf5d8a 100644 --- a/packages/flutter/lib/src/gestures/force_press.dart +++ b/packages/flutter/lib/src/gestures/force_press.dart @@ -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? 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 diff --git a/packages/flutter/lib/src/gestures/long_press.dart b/packages/flutter/lib/src/gestures/long_press.dart index 701b10cf2d..fa6c324f84 100644 --- a/packages/flutter/lib/src/gestures/long_press.dart +++ b/packages/flutter/lib/src/gestures/long_press.dart @@ -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? 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; diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index 24b45681e6..e48caceb69 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -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? 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 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 supportedDevices = _kAllPointerDeviceKinds, - }) : super(debugOwner: debugOwner, kind: kind, supportedDevices: supportedDevices); + Set? 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 _kAllPointerDeviceKinds = { - ...PointerDeviceKind.values, -}; - /// Recognizes movement in the horizontal direction. /// /// Used for horizontal scrolling. @@ -559,12 +563,20 @@ const Set _kAllPointerDeviceKinds = { 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 supportedDevices = _kAllPointerDeviceKinds, - }) : super(debugOwner: debugOwner, kind: kind, supportedDevices: supportedDevices); + Set? supportedDevices, + }) : super( + debugOwner: debugOwner, + kind: kind, + supportedDevices: supportedDevices, + ); @override bool isFlingGesture(VelocityEstimate estimate, PointerDeviceKind kind) { diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 677d10280f..5f5adcac33 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -199,10 +199,21 @@ abstract class MultiDragPointerState { /// start after a long-press gesture. abstract class MultiDragGestureRecognizer 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? 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? 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? 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? 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? 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. diff --git a/packages/flutter/lib/src/gestures/multitap.dart b/packages/flutter/lib/src/gestures/multitap.dart index b76b02bf59..0478a44c00 100644 --- a/packages/flutter/lib/src/gestures/multitap.dart +++ b/packages/flutter/lib/src/gestures/multitap.dart @@ -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? 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? supportedDevices, + }) : super( + debugOwner: debugOwner, + kind: kind, + supportedDevices: supportedDevices, + ); /// A pointer that might cause a tap has contacted the screen at a particular /// location. diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index acd74d4ee1..f904b5d9ae 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -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? supportedDevices, + }) : assert(kind == null || supportedDevices == null), + _supportedDevices = kind == null ? supportedDevices : { 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? _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? supportedDevices, + }) : super( + debugOwner: debugOwner, + kind: kind, + supportedDevices: supportedDevices, + ); final Map _entries = {}; final Set _trackedPointers = HashSet(); @@ -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? 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. diff --git a/packages/flutter/lib/src/gestures/scale.dart b/packages/flutter/lib/src/gestures/scale.dart index 84c2d7489c..7e7e742b82 100644 --- a/packages/flutter/lib/src/gestures/scale.dart +++ b/packages/flutter/lib/src/gestures/scale.dart @@ -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? 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. diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart index a0b0ab3bb6..53894242d7 100644 --- a/packages/flutter/lib/src/rendering/platform_view.dart +++ b/packages/flutter/lib/src/rendering/platform_view.dart @@ -422,8 +422,8 @@ class _UiKitViewGestureRecognizer extends OneSequenceGestureRecognizer { _UiKitViewGestureRecognizer( this.controller, this.gestureRecognizerFactories, { - PointerDeviceKind? kind, - }) : super(kind: kind) { + Set? 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? supportedDevices, + }) : super(supportedDevices: supportedDevices) { team = GestureArenaTeam() ..captain = this; _gestureRecognizers = gestureRecognizerFactories.map( diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index c9398310ce..80a4142d20 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -553,7 +553,7 @@ class ScrollableState extends State with TickerProviderStateMixin, R case Axis.vertical: _gestureRecognizers = { VerticalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( - () => VerticalDragGestureRecognizer(), + () => VerticalDragGestureRecognizer(supportedDevices: _configuration.dragDevices), (VerticalDragGestureRecognizer instance) { instance ..onDown = _handleDragDown @@ -565,8 +565,7 @@ class ScrollableState extends State 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 with TickerProviderStateMixin, R case Axis.horizontal: _gestureRecognizers = { HorizontalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( - () => HorizontalDragGestureRecognizer(), + () => HorizontalDragGestureRecognizer(supportedDevices: _configuration.dragDevices), (HorizontalDragGestureRecognizer instance) { instance ..onDown = _handleDragDown @@ -586,8 +585,7 @@ class ScrollableState extends State with TickerProviderStateMixin, R ..minFlingVelocity = _physics?.minFlingVelocity ..maxFlingVelocity = _physics?.maxFlingVelocity ..velocityTrackerBuilder = _configuration.velocityTrackerBuilder(context) - ..dragStartBehavior = widget.dragStartBehavior - ..supportedDevices = _configuration.dragDevices; + ..dragStartBehavior = widget.dragStartBehavior; }, ), }; diff --git a/packages/flutter/lib/src/widgets/scrollbar.dart b/packages/flutter/lib/src/widgets/scrollbar.dart index accbd5940e..2b24764676 100644 --- a/packages/flutter/lib/src/widgets/scrollbar.dart +++ b/packages/flutter/lib/src/widgets/scrollbar.dart @@ -1383,14 +1383,14 @@ class RawScrollbarState extends State with TickerProv class _ThumbPressGestureRecognizer extends LongPressGestureRecognizer { _ThumbPressGestureRecognizer({ double? postAcceptSlopTolerance, - PointerDeviceKind? kind, + Set? supportedDevices, required Object debugOwner, required GlobalKey customPaintKey, required Duration pressDuration, }) : _customPaintKey = customPaintKey, super( postAcceptSlopTolerance: postAcceptSlopTolerance, - kind: kind, + supportedDevices: supportedDevices, debugOwner: debugOwner, duration: pressDuration, ); diff --git a/packages/flutter/test/gestures/force_press_test.dart b/packages/flutter/test/gestures/force_press_test.dart index afbb3cecf2..d3f5a19c46 100644 --- a/packages/flutter/test/gestures/force_press_test.dart +++ b/packages/flutter/test/gestures/force_press_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } diff --git a/packages/flutter/test/gestures/long_press_test.dart b/packages/flutter/test/gestures/long_press_test.dart index eed71e0dbc..a07de9471f 100644 --- a/packages/flutter/test/gestures/long_press_test.dart +++ b/packages/flutter/test/gestures/long_press_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } diff --git a/packages/flutter/test/gestures/monodrag_test.dart b/packages/flutter/test/gestures/monodrag_test.dart index 3ca3b0712d..5f3d0db401 100644 --- a/packages/flutter/test/gestures/monodrag_test.dart +++ b/packages/flutter/test/gestures/monodrag_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } class MockHitTestTarget implements HitTestTarget { diff --git a/packages/flutter/test/gestures/multidrag_test.dart b/packages/flutter/test/gestures/multidrag_test.dart index ec6cda7eae..d971caaa5c 100644 --- a/packages/flutter/test/gestures/multidrag_test.dart +++ b/packages/flutter/test/gestures/multidrag_test.dart @@ -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.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.touch }, + ); + }, + throwsA( + isA().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.touch }, + ); + }, + throwsA( + isA().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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } diff --git a/packages/flutter/test/gestures/multitap_test.dart b/packages/flutter/test/gestures/multitap_test.dart index 1fa3c153cb..7d0a0449e5 100644 --- a/packages/flutter/test/gestures/multitap_test.dart +++ b/packages/flutter/test/gestures/multitap_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } diff --git a/packages/flutter/test/gestures/recognizer_test.dart b/packages/flutter/test/gestures/recognizer_test.dart index 0d04ac44eb..4aafb19a4e 100644 --- a/packages/flutter/test/gestures/recognizer_test.dart +++ b/packages/flutter/test/gestures/recognizer_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); }); } diff --git a/packages/flutter/test/gestures/scale_test.dart b/packages/flutter/test/gestures/scale_test.dart index aff85e6ead..83a3fc30a9 100644 --- a/packages/flutter/test/gestures/scale_test.dart +++ b/packages/flutter/test/gestures/scale_test.dart @@ -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.touch }, + ); + }, + throwsA( + isA().having((AssertionError error) => error.toString(), + 'description', contains('kind == null || supportedDevices == null')), + ), + ); + }); } diff --git a/packages/flutter/test_fixes/gestures.dart b/packages/flutter/test_fixes/gestures.dart index b80b484ea3..6094c1356a 100644 --- a/packages/flutter/test_fixes/gestures.dart +++ b/packages/flutter/test_fixes/gestures.dart @@ -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); } diff --git a/packages/flutter/test_fixes/gestures.dart.expect b/packages/flutter/test_fixes/gestures.dart.expect index e6ce785cd3..afb4cbb43e 100644 --- a/packages/flutter/test_fixes/gestures.dart.expect +++ b/packages/flutter/test_fixes/gestures.dart.expect @@ -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.touch}); + VerticalDragGestureRecognizer(); + VerticalDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + HorizontalDragGestureRecognizer(); + HorizontalDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + GestureRecognizer(); + GestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + OneSequenceGestureRecognizer(); + OneSequenceGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + PrimaryPointerGestureRecognizer(); + PrimaryPointerGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + EagerGestureRecognizer(); + EagerGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + ForcePressGestureRecognizer(); + ForcePressGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + LongPressGestureRecognizer(); + LongPressGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + MultiDragGestureRecognizer(); + MultiDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + ImmediateMultiDragGestureRecognizer(); + ImmediateMultiDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + HorizontalMultiDragGestureRecognizer(); + HorizontalMultiDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + VerticalMultiDragGestureRecognizer(); + VerticalMultiDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + DelayedMultiDragGestureRecognizer(); + DelayedMultiDragGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + DoubleTapGestureRecognizer(); + DoubleTapGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + MultiTapGestureRecognizer(); + MultiTapGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); + ScaleGestureRecognizer(); + ScaleGestureRecognizer(supportedDevices: {PointerDeviceKind.touch}); }