Unverified Commit 3570cce5 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated kind in GestureRecognizer et al (#119572)

* Remove deprecated kind in GestureRecognizer et al

* Fix null case
parent a27802e2
......@@ -18,11 +18,6 @@ class EagerGestureRecognizer extends OneSequenceGestureRecognizer {
///
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
EagerGestureRecognizer({
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......
......@@ -125,11 +125,6 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
this.peakPressure = 0.85,
this.interpolation = _inverseLerp,
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
}) : assert(peakPressure > startPressure);
......
......@@ -248,11 +248,6 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
LongPressGestureRecognizer({
Duration? duration,
super.postAcceptSlopTolerance = null,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.debugOwner,
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
......
......@@ -75,11 +75,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
DragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
this.dragStartBehavior = DragStartBehavior.start,
this.velocityTrackerBuilder = _defaultBuilder,
super.supportedDevices,
......@@ -554,11 +549,6 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
VerticalDragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......@@ -601,11 +591,6 @@ class HorizontalDragGestureRecognizer extends DragGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
HorizontalDragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......
......@@ -215,11 +215,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
MultiDragGestureRecognizer({
required super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
});
......@@ -371,11 +366,6 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
ImmediateMultiDragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......@@ -429,11 +419,6 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
HorizontalMultiDragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......@@ -487,11 +472,6 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
VerticalMultiDragGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......@@ -597,11 +577,6 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
DelayedMultiDragGestureRecognizer({
this.delay = kLongPressTimeout,
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......
......@@ -118,11 +118,6 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
DoubleTapGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
});
......@@ -486,11 +481,6 @@ class MultiTapGestureRecognizer extends GestureRecognizer {
MultiTapGestureRecognizer({
this.longTapDelay = Duration.zero,
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......
......@@ -78,15 +78,9 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
/// {@endtemplate}
GestureRecognizer({
this.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
PointerDeviceKind? kind,
Set<PointerDeviceKind>? supportedDevices,
AllowedButtonsFilter? allowedButtonsFilter,
}) : assert(kind == null || supportedDevices == null),
_supportedDevices = kind == null ? supportedDevices : <PointerDeviceKind>{ kind },
}) : _supportedDevices = supportedDevices,
_allowedButtonsFilter = allowedButtonsFilter ?? _defaultButtonAcceptBehavior;
/// The recognizer's owner.
......@@ -321,11 +315,6 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
OneSequenceGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
});
......@@ -535,11 +524,6 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni
this.preAcceptSlopTolerance = kTouchSlop,
this.postAcceptSlopTolerance = kTouchSlop,
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
}) : assert(
......
......@@ -321,11 +321,6 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
ScaleGestureRecognizer({
super.debugOwner,
@Deprecated(
'Migrate to supportedDevices. '
'This feature was deprecated after v2.3.0-1.0.pre.',
)
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
this.dragStartBehavior = DragStartBehavior.down,
......
......@@ -697,7 +697,6 @@ class TapAndDragGestureRecognizer extends OneSequenceGestureRecognizer with _Tap
/// {@macro flutter.gestures.GestureRecognizer.supportedDevices}
TapAndDragGestureRecognizer({
super.debugOwner,
super.kind,
super.supportedDevices,
super.allowedButtonsFilter,
}) : _deadline = kPressTimeout,
......
......@@ -730,7 +730,7 @@ void main() {
testGesture('Can filter drags based on device kind', (GestureTester tester) {
final HorizontalDragGestureRecognizer drag =
HorizontalDragGestureRecognizer(
kind: PointerDeviceKind.mouse,
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.mouse },
)
..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
......
......@@ -574,19 +574,4 @@ 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')),
),
);
});
}
......@@ -259,7 +259,9 @@ void main() {
});
testGesture('non-allowed pointer does not inadvertently reset the recognizer', (GestureTester tester) {
gesture = LongPressGestureRecognizer(kind: PointerDeviceKind.touch);
gesture = LongPressGestureRecognizer(
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
);
setUpHandlers();
// Accept a long-press gesture
......@@ -495,7 +497,9 @@ void main() {
});
testGesture('Can filter long press based on device kind', (GestureTester tester) {
final LongPressGestureRecognizer mouseLongPress = LongPressGestureRecognizer(kind: PointerDeviceKind.mouse);
final LongPressGestureRecognizer mouseLongPress = LongPressGestureRecognizer(
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.mouse },
);
bool mouseLongPressDown = false;
mouseLongPress.onLongPress = () {
......@@ -697,19 +701,4 @@ 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')),
),
);
});
}
......@@ -49,36 +49,6 @@ void main() {
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')),
),
);
});
group('Recognizers on different button filters:', () {
final List<String> recognized = <String>[];
late HorizontalDragGestureRecognizer primaryRecognizer;
......
......@@ -63,8 +63,9 @@ void main() {
});
testGesture('MultiDrag: can filter based on device kind', (GestureTester tester) {
final DelayedMultiDragGestureRecognizer drag =
DelayedMultiDragGestureRecognizer(kind: PointerDeviceKind.touch);
final DelayedMultiDragGestureRecognizer drag = DelayedMultiDragGestureRecognizer(
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
);
bool didStartDrag = false;
drag.onStart = (Offset position) {
......@@ -89,61 +90,4 @@ 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')),
),
);
});
}
......@@ -68,11 +68,10 @@ void main() {
});
testGesture('Can filter based on device kind', (GestureTester tester) {
final MultiTapGestureRecognizer tap =
MultiTapGestureRecognizer(
longTapDelay: kLongPressTimeout,
kind: PointerDeviceKind.touch,
);
final MultiTapGestureRecognizer tap = MultiTapGestureRecognizer(
longTapDelay: kLongPressTimeout,
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
);
final List<String> log = <String>[];
......@@ -143,34 +142,4 @@ 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')),
),
);
});
}
......@@ -72,21 +72,6 @@ void main() {
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')),
),
);
});
group('PrimaryPointerGestureRecognizer', () {
testGesture('cleans up state after winning arena', (GestureTester tester) {
final List<String> resolutions = <String>[];
......
......@@ -250,7 +250,9 @@ void main() {
});
testGesture('Rejects scale gestures from unallowed device kinds', (GestureTester tester) {
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(kind: PointerDeviceKind.touch);
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
);
bool didStartScale = false;
scale.onStart = (ScaleStartDetails details) {
......@@ -282,7 +284,9 @@ void main() {
});
testGesture('Scale gestures starting from allowed device kinds cannot be ended from unallowed devices', (GestureTester tester) {
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(kind: PointerDeviceKind.touch);
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(
supportedDevices: <PointerDeviceKind>{ PointerDeviceKind.touch },
);
bool didStartScale = false;
Offset? updatedFocalPoint;
......@@ -1159,21 +1163,6 @@ 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')),
),
);
});
testGesture('scale trackpadScrollCausesScale', (GestureTester tester) {
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(
dragStartBehavior: DragStartBehavior.start,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment