Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 3570cce

Browse files
authored
Remove deprecated kind in GestureRecognizer et al (#119572)
* Remove deprecated kind in GestureRecognizer et al * Fix null case
1 parent a27802e commit 3570cce

17 files changed

+21
-277
lines changed

packages/flutter/lib/src/gestures/eager.dart

-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ class EagerGestureRecognizer extends OneSequenceGestureRecognizer {
1818
///
1919
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
2020
EagerGestureRecognizer({
21-
@Deprecated(
22-
'Migrate to supportedDevices. '
23-
'This feature was deprecated after v2.3.0-1.0.pre.',
24-
)
25-
super.kind,
2621
super.supportedDevices,
2722
super.allowedButtonsFilter,
2823
});

packages/flutter/lib/src/gestures/force_press.dart

-5
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
125125
this.peakPressure = 0.85,
126126
this.interpolation = _inverseLerp,
127127
super.debugOwner,
128-
@Deprecated(
129-
'Migrate to supportedDevices. '
130-
'This feature was deprecated after v2.3.0-1.0.pre.',
131-
)
132-
super.kind,
133128
super.supportedDevices,
134129
super.allowedButtonsFilter,
135130
}) : assert(peakPressure > startPressure);

packages/flutter/lib/src/gestures/long_press.dart

-5
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,6 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
248248
LongPressGestureRecognizer({
249249
Duration? duration,
250250
super.postAcceptSlopTolerance = null,
251-
@Deprecated(
252-
'Migrate to supportedDevices. '
253-
'This feature was deprecated after v2.3.0-1.0.pre.',
254-
)
255-
super.kind,
256251
super.supportedDevices,
257252
super.debugOwner,
258253
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,

packages/flutter/lib/src/gestures/monodrag.dart

-15
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
7575
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
7676
DragGestureRecognizer({
7777
super.debugOwner,
78-
@Deprecated(
79-
'Migrate to supportedDevices. '
80-
'This feature was deprecated after v2.3.0-1.0.pre.',
81-
)
82-
super.kind,
8378
this.dragStartBehavior = DragStartBehavior.start,
8479
this.velocityTrackerBuilder = _defaultBuilder,
8580
super.supportedDevices,
@@ -554,11 +549,6 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer {
554549
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
555550
VerticalDragGestureRecognizer({
556551
super.debugOwner,
557-
@Deprecated(
558-
'Migrate to supportedDevices. '
559-
'This feature was deprecated after v2.3.0-1.0.pre.',
560-
)
561-
super.kind,
562552
super.supportedDevices,
563553
super.allowedButtonsFilter,
564554
});
@@ -601,11 +591,6 @@ class HorizontalDragGestureRecognizer extends DragGestureRecognizer {
601591
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
602592
HorizontalDragGestureRecognizer({
603593
super.debugOwner,
604-
@Deprecated(
605-
'Migrate to supportedDevices. '
606-
'This feature was deprecated after v2.3.0-1.0.pre.',
607-
)
608-
super.kind,
609594
super.supportedDevices,
610595
super.allowedButtonsFilter,
611596
});

packages/flutter/lib/src/gestures/multidrag.dart

-25
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
215215
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
216216
MultiDragGestureRecognizer({
217217
required super.debugOwner,
218-
@Deprecated(
219-
'Migrate to supportedDevices. '
220-
'This feature was deprecated after v2.3.0-1.0.pre.',
221-
)
222-
super.kind,
223218
super.supportedDevices,
224219
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
225220
});
@@ -371,11 +366,6 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
371366
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
372367
ImmediateMultiDragGestureRecognizer({
373368
super.debugOwner,
374-
@Deprecated(
375-
'Migrate to supportedDevices. '
376-
'This feature was deprecated after v2.3.0-1.0.pre.',
377-
)
378-
super.kind,
379369
super.supportedDevices,
380370
super.allowedButtonsFilter,
381371
});
@@ -429,11 +419,6 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
429419
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
430420
HorizontalMultiDragGestureRecognizer({
431421
super.debugOwner,
432-
@Deprecated(
433-
'Migrate to supportedDevices. '
434-
'This feature was deprecated after v2.3.0-1.0.pre.',
435-
)
436-
super.kind,
437422
super.supportedDevices,
438423
super.allowedButtonsFilter,
439424
});
@@ -487,11 +472,6 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
487472
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
488473
VerticalMultiDragGestureRecognizer({
489474
super.debugOwner,
490-
@Deprecated(
491-
'Migrate to supportedDevices. '
492-
'This feature was deprecated after v2.3.0-1.0.pre.',
493-
)
494-
super.kind,
495475
super.supportedDevices,
496476
super.allowedButtonsFilter,
497477
});
@@ -597,11 +577,6 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
597577
DelayedMultiDragGestureRecognizer({
598578
this.delay = kLongPressTimeout,
599579
super.debugOwner,
600-
@Deprecated(
601-
'Migrate to supportedDevices. '
602-
'This feature was deprecated after v2.3.0-1.0.pre.',
603-
)
604-
super.kind,
605580
super.supportedDevices,
606581
super.allowedButtonsFilter,
607582
});

packages/flutter/lib/src/gestures/multitap.dart

-10
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
118118
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
119119
DoubleTapGestureRecognizer({
120120
super.debugOwner,
121-
@Deprecated(
122-
'Migrate to supportedDevices. '
123-
'This feature was deprecated after v2.3.0-1.0.pre.',
124-
)
125-
super.kind,
126121
super.supportedDevices,
127122
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
128123
});
@@ -486,11 +481,6 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
486481
MultiTapGestureRecognizer({
487482
this.longTapDelay = Duration.zero,
488483
super.debugOwner,
489-
@Deprecated(
490-
'Migrate to supportedDevices. '
491-
'This feature was deprecated after v2.3.0-1.0.pre.',
492-
)
493-
super.kind,
494484
super.supportedDevices,
495485
super.allowedButtonsFilter,
496486
});

packages/flutter/lib/src/gestures/recognizer.dart

+1-17
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
7878
/// {@endtemplate}
7979
GestureRecognizer({
8080
this.debugOwner,
81-
@Deprecated(
82-
'Migrate to supportedDevices. '
83-
'This feature was deprecated after v2.3.0-1.0.pre.',
84-
)
85-
PointerDeviceKind? kind,
8681
Set<PointerDeviceKind>? supportedDevices,
8782
AllowedButtonsFilter? allowedButtonsFilter,
88-
}) : assert(kind == null || supportedDevices == null),
89-
_supportedDevices = kind == null ? supportedDevices : <PointerDeviceKind>{ kind },
83+
}) : _supportedDevices = supportedDevices,
9084
_allowedButtonsFilter = allowedButtonsFilter ?? _defaultButtonAcceptBehavior;
9185

9286
/// The recognizer's owner.
@@ -321,11 +315,6 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer {
321315
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
322316
OneSequenceGestureRecognizer({
323317
super.debugOwner,
324-
@Deprecated(
325-
'Migrate to supportedDevices. '
326-
'This feature was deprecated after v2.3.0-1.0.pre.',
327-
)
328-
super.kind,
329318
super.supportedDevices,
330319
super.allowedButtonsFilter,
331320
});
@@ -535,11 +524,6 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
535524
this.preAcceptSlopTolerance = kTouchSlop,
536525
this.postAcceptSlopTolerance = kTouchSlop,
537526
super.debugOwner,
538-
@Deprecated(
539-
'Migrate to supportedDevices. '
540-
'This feature was deprecated after v2.3.0-1.0.pre.',
541-
)
542-
super.kind,
543527
super.supportedDevices,
544528
super.allowedButtonsFilter,
545529
}) : assert(

packages/flutter/lib/src/gestures/scale.dart

-5
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
321321
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
322322
ScaleGestureRecognizer({
323323
super.debugOwner,
324-
@Deprecated(
325-
'Migrate to supportedDevices. '
326-
'This feature was deprecated after v2.3.0-1.0.pre.',
327-
)
328-
super.kind,
329324
super.supportedDevices,
330325
super.allowedButtonsFilter,
331326
this.dragStartBehavior = DragStartBehavior.down,

packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart

-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ class TapAndDragGestureRecognizer extends OneSequenceGestureRecognizer with _Tap
697697
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
698698
TapAndDragGestureRecognizer({
699699
super.debugOwner,
700-
super.kind,
701700
super.supportedDevices,
702701
super.allowedButtonsFilter,
703702
}) : _deadline = kPressTimeout,

packages/flutter/test/gestures/drag_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ void main() {
730730
testGesture('Can filter drags based on device kind', (GestureTester tester) {
731731
final HorizontalDragGestureRecognizer drag =
732732
HorizontalDragGestureRecognizer(
733-
kind: PointerDeviceKind.mouse,
733+
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.mouse },
734734
)
735735
..dragStartBehavior = DragStartBehavior.down;
736736
addTearDown(drag.dispose);

packages/flutter/test/gestures/force_press_test.dart

-15
Original file line numberDiff line numberDiff line change
@@ -574,19 +574,4 @@ void main() {
574574
expect(updated, 1);
575575
expect(ended, 1);
576576
});
577-
578-
testWidgets('ForecePressGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
579-
expect(
580-
() {
581-
ForcePressGestureRecognizer(
582-
kind: PointerDeviceKind.touch,
583-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
584-
);
585-
},
586-
throwsA(
587-
isA<AssertionError>().having((AssertionError error) => error.toString(),
588-
'description', contains('kind == null || supportedDevices == null')),
589-
),
590-
);
591-
});
592577
}

packages/flutter/test/gestures/long_press_test.dart

+6-17
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ void main() {
259259
});
260260

261261
testGesture('non-allowed pointer does not inadvertently reset the recognizer', (GestureTester tester) {
262-
gesture = LongPressGestureRecognizer(kind: PointerDeviceKind.touch);
262+
gesture = LongPressGestureRecognizer(
263+
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
264+
);
263265
setUpHandlers();
264266

265267
// Accept a long-press gesture
@@ -495,7 +497,9 @@ void main() {
495497
});
496498

497499
testGesture('Can filter long press based on device kind', (GestureTester tester) {
498-
final LongPressGestureRecognizer mouseLongPress = LongPressGestureRecognizer(kind: PointerDeviceKind.mouse);
500+
final LongPressGestureRecognizer mouseLongPress = LongPressGestureRecognizer(
501+
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.mouse },
502+
);
499503

500504
bool mouseLongPressDown = false;
501505
mouseLongPress.onLongPress = () {
@@ -697,19 +701,4 @@ void main() {
697701
longPress.dispose();
698702
recognized.clear();
699703
});
700-
701-
testWidgets('LongPressGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
702-
expect(
703-
() {
704-
LongPressGestureRecognizer(
705-
kind: PointerDeviceKind.touch,
706-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
707-
);
708-
},
709-
throwsA(
710-
isA<AssertionError>().having((AssertionError error) => error.toString(),
711-
'description', contains('kind == null || supportedDevices == null')),
712-
),
713-
);
714-
});
715704
}

packages/flutter/test/gestures/monodrag_test.dart

-30
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,6 @@ void main() {
4949
GestureBinding.instance.handleEvent(up91, HitTestEntry(MockHitTestTarget()));
5050
});
5151

52-
testWidgets('VerticalDragGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
53-
expect(
54-
() {
55-
VerticalDragGestureRecognizer(
56-
kind: PointerDeviceKind.touch,
57-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
58-
);
59-
},
60-
throwsA(
61-
isA<AssertionError>().having((AssertionError error) => error.toString(),
62-
'description', contains('kind == null || supportedDevices == null')),
63-
),
64-
);
65-
});
66-
67-
testWidgets('HorizontalDragGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
68-
expect(
69-
() {
70-
HorizontalDragGestureRecognizer(
71-
kind: PointerDeviceKind.touch,
72-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
73-
);
74-
},
75-
throwsA(
76-
isA<AssertionError>().having((AssertionError error) => error.toString(),
77-
'description', contains('kind == null || supportedDevices == null')),
78-
),
79-
);
80-
});
81-
8252
group('Recognizers on different button filters:', () {
8353
final List<String> recognized = <String>[];
8454
late HorizontalDragGestureRecognizer primaryRecognizer;

packages/flutter/test/gestures/multidrag_test.dart

+3-59
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ void main() {
6363
});
6464

6565
testGesture('MultiDrag: can filter based on device kind', (GestureTester tester) {
66-
final DelayedMultiDragGestureRecognizer drag =
67-
DelayedMultiDragGestureRecognizer(kind: PointerDeviceKind.touch);
66+
final DelayedMultiDragGestureRecognizer drag = DelayedMultiDragGestureRecognizer(
67+
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
68+
);
6869

6970
bool didStartDrag = false;
7071
drag.onStart = (Offset position) {
@@ -89,61 +90,4 @@ void main() {
8990
expect(didStartDrag, isFalse);
9091
drag.dispose();
9192
});
92-
93-
testWidgets('ImmediateMultiGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
94-
try {
95-
ImmediateMultiDragGestureRecognizer(
96-
kind: PointerDeviceKind.touch,
97-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
98-
);
99-
} catch(error) {
100-
expect(error, isAssertionError);
101-
expect(error.toString(), contains('kind == null || supportedDevices == null'));
102-
}
103-
});
104-
105-
testWidgets('HorizontalMultiDragGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
106-
expect(
107-
() {
108-
HorizontalMultiDragGestureRecognizer(
109-
kind: PointerDeviceKind.touch,
110-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
111-
);
112-
},
113-
throwsA(
114-
isA<AssertionError>().having((AssertionError error) => error.toString(),
115-
'description', contains('kind == null || supportedDevices == null')),
116-
),
117-
);
118-
});
119-
120-
testWidgets('VerticalMultiDragGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
121-
expect(
122-
() {
123-
VerticalMultiDragGestureRecognizer(
124-
kind: PointerDeviceKind.touch,
125-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
126-
);
127-
},
128-
throwsA(
129-
isA<AssertionError>().having((AssertionError error) => error.toString(),
130-
'description', contains('kind == null || supportedDevices == null')),
131-
),
132-
);
133-
});
134-
135-
testWidgets('DelayedMultiDragGestureRecognizer asserts when kind and supportedDevices are both set', (WidgetTester tester) async {
136-
expect(
137-
() {
138-
DelayedMultiDragGestureRecognizer(
139-
kind: PointerDeviceKind.touch,
140-
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
141-
);
142-
},
143-
throwsA(
144-
isA<AssertionError>().having((AssertionError error) => error.toString(),
145-
'description', contains('kind == null || supportedDevices == null')),
146-
),
147-
);
148-
});
14993
}

0 commit comments

Comments
 (0)