Unverified Commit f6dc4db2 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false in flutter/lib/src/gestures (#45504)

* implicit-casts:false in flutter/lib/src/gestures

* address review comments
parent e766ae74
...@@ -632,7 +632,7 @@ class PointerAddedEvent extends PointerEvent { ...@@ -632,7 +632,7 @@ class PointerAddedEvent extends PointerEvent {
orientation: orientation, orientation: orientation,
tilt: tilt, tilt: tilt,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerAddedEvent ?? this,
); );
} }
} }
...@@ -694,7 +694,7 @@ class PointerRemovedEvent extends PointerEvent { ...@@ -694,7 +694,7 @@ class PointerRemovedEvent extends PointerEvent {
radiusMin: radiusMin, radiusMin: radiusMin,
radiusMax: radiusMax, radiusMax: radiusMax,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerRemovedEvent ?? this,
); );
} }
} }
...@@ -799,7 +799,7 @@ class PointerHoverEvent extends PointerEvent { ...@@ -799,7 +799,7 @@ class PointerHoverEvent extends PointerEvent {
tilt: tilt, tilt: tilt,
synthesized: synthesized, synthesized: synthesized,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerHoverEvent ?? this,
); );
} }
} }
...@@ -907,7 +907,7 @@ class PointerEnterEvent extends PointerEvent { ...@@ -907,7 +907,7 @@ class PointerEnterEvent extends PointerEvent {
down: event?.down, down: event?.down,
synthesized: event?.synthesized, synthesized: event?.synthesized,
transform: event?.transform, transform: event?.transform,
original: event?.original, original: event?.original as PointerEnterEvent,
); );
@override @override
...@@ -945,7 +945,7 @@ class PointerEnterEvent extends PointerEvent { ...@@ -945,7 +945,7 @@ class PointerEnterEvent extends PointerEvent {
down: down, down: down,
synthesized: synthesized, synthesized: synthesized,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerEnterEvent ?? this,
); );
} }
} }
...@@ -1053,7 +1053,7 @@ class PointerExitEvent extends PointerEvent { ...@@ -1053,7 +1053,7 @@ class PointerExitEvent extends PointerEvent {
down: event?.down, down: event?.down,
synthesized: event?.synthesized, synthesized: event?.synthesized,
transform: event?.transform, transform: event?.transform,
original: event?.original, original: event?.original as PointerExitEvent,
); );
@override @override
...@@ -1091,7 +1091,7 @@ class PointerExitEvent extends PointerEvent { ...@@ -1091,7 +1091,7 @@ class PointerExitEvent extends PointerEvent {
down: down, down: down,
synthesized: synthesized, synthesized: synthesized,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerExitEvent ?? this,
); );
} }
} }
...@@ -1175,7 +1175,7 @@ class PointerDownEvent extends PointerEvent { ...@@ -1175,7 +1175,7 @@ class PointerDownEvent extends PointerEvent {
orientation: orientation, orientation: orientation,
tilt: tilt, tilt: tilt,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerDownEvent ?? this,
); );
} }
} }
...@@ -1284,7 +1284,7 @@ class PointerMoveEvent extends PointerEvent { ...@@ -1284,7 +1284,7 @@ class PointerMoveEvent extends PointerEvent {
platformData: platformData, platformData: platformData,
synthesized: synthesized, synthesized: synthesized,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerMoveEvent ?? this,
); );
} }
} }
...@@ -1372,7 +1372,7 @@ class PointerUpEvent extends PointerEvent { ...@@ -1372,7 +1372,7 @@ class PointerUpEvent extends PointerEvent {
orientation: orientation, orientation: orientation,
tilt: tilt, tilt: tilt,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerUpEvent ?? this,
); );
} }
} }
...@@ -1454,7 +1454,7 @@ class PointerScrollEvent extends PointerSignalEvent { ...@@ -1454,7 +1454,7 @@ class PointerScrollEvent extends PointerSignalEvent {
localPosition: PointerEvent.transformPosition(transform, position), localPosition: PointerEvent.transformPosition(transform, position),
scrollDelta: scrollDelta, scrollDelta: scrollDelta,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerScrollEvent ?? this,
); );
} }
...@@ -1544,7 +1544,7 @@ class PointerCancelEvent extends PointerEvent { ...@@ -1544,7 +1544,7 @@ class PointerCancelEvent extends PointerEvent {
orientation: orientation, orientation: orientation,
tilt: tilt, tilt: tilt,
transform: transform, transform: transform,
original: original ?? this, original: original as PointerCancelEvent ?? this,
); );
} }
} }
...@@ -341,7 +341,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -341,7 +341,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
// If the device incorrectly reports a pressure outside of pressureMin // If the device incorrectly reports a pressure outside of pressureMin
// and pressureMax, we still want this recognizer to respond normally. // and pressureMax, we still want this recognizer to respond normally.
if (!value.isNaN) if (!value.isNaN)
value = value.clamp(0.0, 1.0); value = value.clamp(0.0, 1.0) as double;
return value; return value;
} }
......
...@@ -142,7 +142,7 @@ class HitTestResult { ...@@ -142,7 +142,7 @@ class HitTestResult {
'matrix through PointerEvent.removePerspectiveTransform?' 'matrix through PointerEvent.removePerspectiveTransform?'
'The provided matrix is:\n$transform' 'The provided matrix is:\n$transform'
); );
_transforms.add(_transforms.isEmpty ? transform : transform * _transforms.last); _transforms.add(_transforms.isEmpty ? transform : (transform * _transforms.last as Matrix4));
} }
/// Removes the last transform added via [pushTransform]. /// Removes the last transform added via [pushTransform].
......
...@@ -218,7 +218,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -218,7 +218,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
return false; return false;
} }
} }
return super.isPointerAllowed(event); return super.isPointerAllowed(event as PointerDownEvent);
} }
@override @override
...@@ -412,7 +412,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -412,7 +412,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
assert(tracker != null); assert(tracker != null);
DragEndDetails details; DragEndDetails details;
void Function() debugReport; String Function() debugReport;
final VelocityEstimate estimate = tracker.getVelocityEstimate(); final VelocityEstimate estimate = tracker.getVelocityEstimate();
if (estimate != null && isFlingGesture(estimate)) { if (estimate != null && isFlingGesture(estimate)) {
......
...@@ -264,7 +264,7 @@ class MouseTracker extends ChangeNotifier { ...@@ -264,7 +264,7 @@ class MouseTracker extends ChangeNotifier {
? LinkedHashSet<MouseTrackerAnnotation>.from( ? LinkedHashSet<MouseTrackerAnnotation>.from(
annotationFinder(mouseState.mostRecentEvent.position) annotationFinder(mouseState.mostRecentEvent.position)
) )
: <MouseTrackerAnnotation>{}; : <MouseTrackerAnnotation>{} as LinkedHashSet<MouseTrackerAnnotation>;
_dispatchDeviceCallbacks( _dispatchDeviceCallbacks(
currentState: mouseState, currentState: mouseState,
......
...@@ -168,7 +168,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -168,7 +168,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
return false; return false;
} }
} }
return super.isPointerAllowed(event); return super.isPointerAllowed(event as PointerDownEvent);
} }
@override @override
...@@ -177,7 +177,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -177,7 +177,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
if (!_firstTap.isWithinGlobalTolerance(event, kDoubleTapSlop)) { if (!_firstTap.isWithinGlobalTolerance(event, kDoubleTapSlop)) {
// Ignore out-of-bounds second taps. // Ignore out-of-bounds second taps.
return; return;
} else if (!_firstTap.hasElapsedMinTime() || !_firstTap.hasSameButton(event)) { } else if (!_firstTap.hasElapsedMinTime() || !_firstTap.hasSameButton(event as PointerDownEvent)) {
// Restart when the second tap is too close to the first, or when buttons // Restart when the second tap is too close to the first, or when buttons
// mismatch. // mismatch.
_reset(); _reset();
...@@ -190,7 +190,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -190,7 +190,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
void _trackFirstTap(PointerEvent event) { void _trackFirstTap(PointerEvent event) {
_stopDoubleTapTimer(); _stopDoubleTapTimer();
final _TapTracker tracker = _TapTracker( final _TapTracker tracker = _TapTracker(
event: event, event: event as PointerDownEvent,
entry: GestureBinding.instance.gestureArena.add(event.pointer, this), entry: GestureBinding.instance.gestureArena.add(event.pointer, this),
doubleTapMinTime: kDoubleTapMinTime, doubleTapMinTime: kDoubleTapMinTime,
); );
...@@ -322,7 +322,7 @@ class _TapGesture extends _TapTracker { ...@@ -322,7 +322,7 @@ class _TapGesture extends _TapTracker {
Duration longTapDelay, Duration longTapDelay,
}) : _lastPosition = OffsetPair.fromEventPosition(event), }) : _lastPosition = OffsetPair.fromEventPosition(event),
super( super(
event: event, event: event as PointerDownEvent,
entry: GestureBinding.instance.gestureArena.add(event.pointer, gestureRecognizer), entry: GestureBinding.instance.gestureArena.add(event.pointer, gestureRecognizer),
doubleTapMinTime: kDoubleTapMinTime, doubleTapMinTime: kDoubleTapMinTime,
) { ) {
......
...@@ -63,10 +63,8 @@ class Velocity { ...@@ -63,10 +63,8 @@ class Velocity {
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
if (other is! Velocity) return other is Velocity
return false; && other.pixelsPerSecond == pixelsPerSecond;
final Velocity typedOther = other;
return pixelsPerSecond == typedOther.pixelsPerSecond;
} }
@override @override
......
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