Unverified Commit 224e6aa1 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in flutter/gestures (#118926)

parent 90ffb1c6
...@@ -266,7 +266,6 @@ class GestureArenaManager { ...@@ -266,7 +266,6 @@ class GestureArenaManager {
void _resolveInFavorOf(int pointer, _GestureArena state, GestureArenaMember member) { void _resolveInFavorOf(int pointer, _GestureArena state, GestureArenaMember member) {
assert(state == _arenas[pointer]); assert(state == _arenas[pointer]);
assert(state != null);
assert(state.eagerWinner == null || state.eagerWinner == member); assert(state.eagerWinner == null || state.eagerWinner == member);
assert(!state.isOpen); assert(!state.isOpen);
_arenas.remove(pointer); _arenas.remove(pointer);
......
...@@ -83,8 +83,6 @@ class _Resampler { ...@@ -83,8 +83,6 @@ class _Resampler {
// Add `event` for resampling or dispatch it directly if // Add `event` for resampling or dispatch it directly if
// not a touch event. // not a touch event.
void addOrDispatch(PointerEvent event) { void addOrDispatch(PointerEvent event) {
final SchedulerBinding scheduler = SchedulerBinding.instance;
assert(scheduler != null);
// Add touch event to resampler or dispatch pointer event directly. // Add touch event to resampler or dispatch pointer event directly.
if (event.kind == PointerDeviceKind.touch) { if (event.kind == PointerDeviceKind.touch) {
// Save last event time for debugPrint of resampling margin. // Save last event time for debugPrint of resampling margin.
...@@ -108,7 +106,6 @@ class _Resampler { ...@@ -108,7 +106,6 @@ class _Resampler {
// The `samplingClock` is the clock used to determine frame time age. // The `samplingClock` is the clock used to determine frame time age.
void sample(Duration samplingOffset, SamplingClock clock) { void sample(Duration samplingOffset, SamplingClock clock) {
final SchedulerBinding scheduler = SchedulerBinding.instance; final SchedulerBinding scheduler = SchedulerBinding.instance;
assert(scheduler != null);
// Initialize `_frameTime` if needed. This will be used for periodic // Initialize `_frameTime` if needed. This will be used for periodic
// sampling when frame callbacks are not received. // sampling when frame callbacks are not received.
...@@ -391,7 +388,6 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H ...@@ -391,7 +388,6 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
if (hitTestResult != null || if (hitTestResult != null ||
event is PointerAddedEvent || event is PointerAddedEvent ||
event is PointerRemovedEvent) { event is PointerRemovedEvent) {
assert(event.position != null);
dispatchEvent(event, hitTestResult); dispatchEvent(event, hitTestResult);
} }
} }
......
...@@ -54,7 +54,6 @@ class PointerEventConverter { ...@@ -54,7 +54,6 @@ class PointerEventConverter {
.where((ui.PointerData datum) => datum.signalKind != ui.PointerSignalKind.unknown) .where((ui.PointerData datum) => datum.signalKind != ui.PointerSignalKind.unknown)
.map((ui.PointerData datum) { .map((ui.PointerData datum) {
final Offset position = Offset(datum.physicalX, datum.physicalY) / devicePixelRatio; final Offset position = Offset(datum.physicalX, datum.physicalY) / devicePixelRatio;
assert(position != null);
final Offset delta = Offset(datum.physicalDeltaX, datum.physicalDeltaY) / devicePixelRatio; final Offset delta = Offset(datum.physicalDeltaX, datum.physicalDeltaY) / devicePixelRatio;
final double radiusMinor = _toLogicalPixels(datum.radiusMinor, devicePixelRatio); final double radiusMinor = _toLogicalPixels(datum.radiusMinor, devicePixelRatio);
final double radiusMajor = _toLogicalPixels(datum.radiusMajor, devicePixelRatio); final double radiusMajor = _toLogicalPixels(datum.radiusMajor, devicePixelRatio);
...@@ -62,7 +61,6 @@ class PointerEventConverter { ...@@ -62,7 +61,6 @@ class PointerEventConverter {
final double radiusMax = _toLogicalPixels(datum.radiusMax, devicePixelRatio); final double radiusMax = _toLogicalPixels(datum.radiusMax, devicePixelRatio);
final Duration timeStamp = datum.timeStamp; final Duration timeStamp = datum.timeStamp;
final PointerDeviceKind kind = datum.kind; final PointerDeviceKind kind = datum.kind;
assert(datum.change != null);
switch (datum.signalKind ?? ui.PointerSignalKind.none) { switch (datum.signalKind ?? ui.PointerSignalKind.none) {
case ui.PointerSignalKind.none: case ui.PointerSignalKind.none:
switch (datum.change) { switch (datum.change) {
......
...@@ -25,8 +25,7 @@ class DragDownDetails { ...@@ -25,8 +25,7 @@ class DragDownDetails {
DragDownDetails({ DragDownDetails({
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
/// ///
...@@ -73,8 +72,7 @@ class DragStartDetails { ...@@ -73,8 +72,7 @@ class DragStartDetails {
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
this.kind, this.kind,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// Recorded timestamp of the source pointer event that triggered the drag /// Recorded timestamp of the source pointer event that triggered the drag
/// event. /// event.
...@@ -142,8 +140,7 @@ class DragUpdateDetails { ...@@ -142,8 +140,7 @@ class DragUpdateDetails {
this.primaryDelta, this.primaryDelta,
required this.globalPosition, required this.globalPosition,
Offset? localPosition, Offset? localPosition,
}) : assert(delta != null), }) : assert(
assert(
primaryDelta == null primaryDelta == null
|| (primaryDelta == delta.dx && delta.dy == 0.0) || (primaryDelta == delta.dx && delta.dy == 0.0)
|| (primaryDelta == delta.dy && delta.dx == 0.0), || (primaryDelta == delta.dy && delta.dx == 0.0),
...@@ -223,8 +220,7 @@ class DragEndDetails { ...@@ -223,8 +220,7 @@ class DragEndDetails {
DragEndDetails({ DragEndDetails({
this.velocity = Velocity.zero, this.velocity = Velocity.zero,
this.primaryVelocity, this.primaryVelocity,
}) : assert(velocity != null), }) : assert(
assert(
primaryVelocity == null primaryVelocity == null
|| primaryVelocity == velocity.pixelsPerSecond.dx || primaryVelocity == velocity.pixelsPerSecond.dx
|| primaryVelocity == velocity.pixelsPerSecond.dy, || primaryVelocity == velocity.pixelsPerSecond.dy,
......
...@@ -843,8 +843,7 @@ class PointerAddedEvent extends PointerEvent with _PointerEventDescription, _Cop ...@@ -843,8 +843,7 @@ class PointerAddedEvent extends PointerEvent with _PointerEventDescription, _Cop
} }
class _TransformedPointerAddedEvent extends _TransformedPointerEvent with _CopyPointerAddedEvent implements PointerAddedEvent { class _TransformedPointerAddedEvent extends _TransformedPointerEvent with _CopyPointerAddedEvent implements PointerAddedEvent {
_TransformedPointerAddedEvent(this.original, this.transform) _TransformedPointerAddedEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerAddedEvent original; final PointerAddedEvent original;
...@@ -934,8 +933,7 @@ class PointerRemovedEvent extends PointerEvent with _PointerEventDescription, _C ...@@ -934,8 +933,7 @@ class PointerRemovedEvent extends PointerEvent with _PointerEventDescription, _C
} }
class _TransformedPointerRemovedEvent extends _TransformedPointerEvent with _CopyPointerRemovedEvent implements PointerRemovedEvent { class _TransformedPointerRemovedEvent extends _TransformedPointerEvent with _CopyPointerRemovedEvent implements PointerRemovedEvent {
_TransformedPointerRemovedEvent(this.original, this.transform) _TransformedPointerRemovedEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerRemovedEvent original; final PointerRemovedEvent original;
...@@ -1051,8 +1049,7 @@ class PointerHoverEvent extends PointerEvent with _PointerEventDescription, _Cop ...@@ -1051,8 +1049,7 @@ class PointerHoverEvent extends PointerEvent with _PointerEventDescription, _Cop
} }
class _TransformedPointerHoverEvent extends _TransformedPointerEvent with _CopyPointerHoverEvent implements PointerHoverEvent { class _TransformedPointerHoverEvent extends _TransformedPointerEvent with _CopyPointerHoverEvent implements PointerHoverEvent {
_TransformedPointerHoverEvent(this.original, this.transform) _TransformedPointerHoverEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerHoverEvent original; final PointerHoverEvent original;
...@@ -1198,8 +1195,7 @@ class PointerEnterEvent extends PointerEvent with _PointerEventDescription, _Cop ...@@ -1198,8 +1195,7 @@ class PointerEnterEvent extends PointerEvent with _PointerEventDescription, _Cop
} }
class _TransformedPointerEnterEvent extends _TransformedPointerEvent with _CopyPointerEnterEvent implements PointerEnterEvent { class _TransformedPointerEnterEvent extends _TransformedPointerEvent with _CopyPointerEnterEvent implements PointerEnterEvent {
_TransformedPointerEnterEvent(this.original, this.transform) _TransformedPointerEnterEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerEnterEvent original; final PointerEnterEvent original;
...@@ -1344,8 +1340,7 @@ class PointerExitEvent extends PointerEvent with _PointerEventDescription, _Copy ...@@ -1344,8 +1340,7 @@ class PointerExitEvent extends PointerEvent with _PointerEventDescription, _Copy
} }
class _TransformedPointerExitEvent extends _TransformedPointerEvent with _CopyPointerExitEvent implements PointerExitEvent { class _TransformedPointerExitEvent extends _TransformedPointerEvent with _CopyPointerExitEvent implements PointerExitEvent {
_TransformedPointerExitEvent(this.original, this.transform) _TransformedPointerExitEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerExitEvent original; final PointerExitEvent original;
...@@ -1453,8 +1448,7 @@ class PointerDownEvent extends PointerEvent with _PointerEventDescription, _Copy ...@@ -1453,8 +1448,7 @@ class PointerDownEvent extends PointerEvent with _PointerEventDescription, _Copy
} }
class _TransformedPointerDownEvent extends _TransformedPointerEvent with _CopyPointerDownEvent implements PointerDownEvent { class _TransformedPointerDownEvent extends _TransformedPointerEvent with _CopyPointerDownEvent implements PointerDownEvent {
_TransformedPointerDownEvent(this.original, this.transform) _TransformedPointerDownEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerDownEvent original; final PointerDownEvent original;
...@@ -1571,8 +1565,7 @@ class PointerMoveEvent extends PointerEvent with _PointerEventDescription, _Copy ...@@ -1571,8 +1565,7 @@ class PointerMoveEvent extends PointerEvent with _PointerEventDescription, _Copy
} }
class _TransformedPointerMoveEvent extends _TransformedPointerEvent with _CopyPointerMoveEvent implements PointerMoveEvent { class _TransformedPointerMoveEvent extends _TransformedPointerEvent with _CopyPointerMoveEvent implements PointerMoveEvent {
_TransformedPointerMoveEvent(this.original, this.transform) _TransformedPointerMoveEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerMoveEvent original; final PointerMoveEvent original;
...@@ -1684,8 +1677,7 @@ class PointerUpEvent extends PointerEvent with _PointerEventDescription, _CopyPo ...@@ -1684,8 +1677,7 @@ class PointerUpEvent extends PointerEvent with _PointerEventDescription, _CopyPo
} }
class _TransformedPointerUpEvent extends _TransformedPointerEvent with _CopyPointerUpEvent implements PointerUpEvent { class _TransformedPointerUpEvent extends _TransformedPointerEvent with _CopyPointerUpEvent implements PointerUpEvent {
_TransformedPointerUpEvent(this.original, this.transform) _TransformedPointerUpEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerUpEvent original; final PointerUpEvent original;
...@@ -1784,11 +1776,7 @@ class PointerScrollEvent extends PointerSignalEvent with _PointerEventDescriptio ...@@ -1784,11 +1776,7 @@ class PointerScrollEvent extends PointerSignalEvent with _PointerEventDescriptio
super.position, super.position,
this.scrollDelta = Offset.zero, this.scrollDelta = Offset.zero,
super.embedderId, super.embedderId,
}) : assert(timeStamp != null), });
assert(kind != null),
assert(device != null),
assert(position != null),
assert(scrollDelta != null);
@override @override
final Offset scrollDelta; final Offset scrollDelta;
...@@ -1809,8 +1797,7 @@ class PointerScrollEvent extends PointerSignalEvent with _PointerEventDescriptio ...@@ -1809,8 +1797,7 @@ class PointerScrollEvent extends PointerSignalEvent with _PointerEventDescriptio
} }
class _TransformedPointerScrollEvent extends _TransformedPointerEvent with _CopyPointerScrollEvent implements PointerScrollEvent { class _TransformedPointerScrollEvent extends _TransformedPointerEvent with _CopyPointerScrollEvent implements PointerScrollEvent {
_TransformedPointerScrollEvent(this.original, this.transform) _TransformedPointerScrollEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerScrollEvent original; final PointerScrollEvent original;
...@@ -1888,10 +1875,7 @@ class PointerScrollInertiaCancelEvent extends PointerSignalEvent with _PointerEv ...@@ -1888,10 +1875,7 @@ class PointerScrollInertiaCancelEvent extends PointerSignalEvent with _PointerEv
super.device, super.device,
super.position, super.position,
super.embedderId, super.embedderId,
}) : assert(timeStamp != null), });
assert(kind != null),
assert(device != null),
assert(position != null);
@override @override
PointerScrollInertiaCancelEvent transformed(Matrix4? transform) { PointerScrollInertiaCancelEvent transformed(Matrix4? transform) {
...@@ -1903,8 +1887,7 @@ class PointerScrollInertiaCancelEvent extends PointerSignalEvent with _PointerEv ...@@ -1903,8 +1887,7 @@ class PointerScrollInertiaCancelEvent extends PointerSignalEvent with _PointerEv
} }
class _TransformedPointerScrollInertiaCancelEvent extends _TransformedPointerEvent with _CopyPointerScrollInertiaCancelEvent implements PointerScrollInertiaCancelEvent { class _TransformedPointerScrollInertiaCancelEvent extends _TransformedPointerEvent with _CopyPointerScrollInertiaCancelEvent implements PointerScrollInertiaCancelEvent {
_TransformedPointerScrollInertiaCancelEvent(this.original, this.transform) _TransformedPointerScrollInertiaCancelEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerScrollInertiaCancelEvent original; final PointerScrollInertiaCancelEvent original;
...@@ -1979,12 +1962,7 @@ class PointerScaleEvent extends PointerSignalEvent with _PointerEventDescription ...@@ -1979,12 +1962,7 @@ class PointerScaleEvent extends PointerSignalEvent with _PointerEventDescription
super.position, super.position,
super.embedderId, super.embedderId,
this.scale = 1.0, this.scale = 1.0,
}) : assert(timeStamp != null), });
assert(kind != null),
assert(device != null),
assert(position != null),
assert(embedderId != null),
assert(scale != null);
@override @override
final double scale; final double scale;
...@@ -1999,8 +1977,7 @@ class PointerScaleEvent extends PointerSignalEvent with _PointerEventDescription ...@@ -1999,8 +1977,7 @@ class PointerScaleEvent extends PointerSignalEvent with _PointerEventDescription
} }
class _TransformedPointerScaleEvent extends _TransformedPointerEvent with _CopyPointerScaleEvent implements PointerScaleEvent { class _TransformedPointerScaleEvent extends _TransformedPointerEvent with _CopyPointerScaleEvent implements PointerScaleEvent {
_TransformedPointerScaleEvent(this.original, this.transform) _TransformedPointerScaleEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerScaleEvent original; final PointerScaleEvent original;
...@@ -2068,13 +2045,7 @@ class PointerPanZoomStartEvent extends PointerEvent with _PointerEventDescriptio ...@@ -2068,13 +2045,7 @@ class PointerPanZoomStartEvent extends PointerEvent with _PointerEventDescriptio
super.position, super.position,
super.embedderId, super.embedderId,
super.synthesized, super.synthesized,
}) : assert(timeStamp != null), }) : super(kind: PointerDeviceKind.trackpad);
assert(device != null),
assert(pointer != null),
assert(position != null),
assert(embedderId != null),
assert(synthesized != null),
super(kind: PointerDeviceKind.trackpad);
@override @override
PointerPanZoomStartEvent transformed(Matrix4? transform) { PointerPanZoomStartEvent transformed(Matrix4? transform) {
...@@ -2086,8 +2057,7 @@ class PointerPanZoomStartEvent extends PointerEvent with _PointerEventDescriptio ...@@ -2086,8 +2057,7 @@ class PointerPanZoomStartEvent extends PointerEvent with _PointerEventDescriptio
} }
class _TransformedPointerPanZoomStartEvent extends _TransformedPointerEvent with _CopyPointerPanZoomStartEvent implements PointerPanZoomStartEvent { class _TransformedPointerPanZoomStartEvent extends _TransformedPointerEvent with _CopyPointerPanZoomStartEvent implements PointerPanZoomStartEvent {
_TransformedPointerPanZoomStartEvent(this.original, this.transform) _TransformedPointerPanZoomStartEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerPanZoomStartEvent original; final PointerPanZoomStartEvent original;
...@@ -2179,17 +2149,7 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti ...@@ -2179,17 +2149,7 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti
this.scale = 1.0, this.scale = 1.0,
this.rotation = 0.0, this.rotation = 0.0,
super.synthesized, super.synthesized,
}) : assert(timeStamp != null), }) : super(kind: PointerDeviceKind.trackpad);
assert(device != null),
assert(pointer != null),
assert(position != null),
assert(embedderId != null),
assert(pan != null),
assert(panDelta != null),
assert(scale != null),
assert(rotation != null),
assert(synthesized != null),
super(kind: PointerDeviceKind.trackpad);
@override @override
final Offset pan; final Offset pan;
...@@ -2214,8 +2174,7 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti ...@@ -2214,8 +2174,7 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti
} }
class _TransformedPointerPanZoomUpdateEvent extends _TransformedPointerEvent with _CopyPointerPanZoomUpdateEvent implements PointerPanZoomUpdateEvent { class _TransformedPointerPanZoomUpdateEvent extends _TransformedPointerEvent with _CopyPointerPanZoomUpdateEvent implements PointerPanZoomUpdateEvent {
_TransformedPointerPanZoomUpdateEvent(this.original, this.transform) _TransformedPointerPanZoomUpdateEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
Offset get pan => original.pan; Offset get pan => original.pan;
...@@ -2303,13 +2262,7 @@ class PointerPanZoomEndEvent extends PointerEvent with _PointerEventDescription, ...@@ -2303,13 +2262,7 @@ class PointerPanZoomEndEvent extends PointerEvent with _PointerEventDescription,
super.position, super.position,
super.embedderId, super.embedderId,
super.synthesized, super.synthesized,
}) : assert(timeStamp != null), }) : super(kind: PointerDeviceKind.trackpad);
assert(device != null),
assert(pointer != null),
assert(position != null),
assert(embedderId != null),
assert(synthesized != null),
super(kind: PointerDeviceKind.trackpad);
@override @override
PointerPanZoomEndEvent transformed(Matrix4? transform) { PointerPanZoomEndEvent transformed(Matrix4? transform) {
...@@ -2321,8 +2274,7 @@ class PointerPanZoomEndEvent extends PointerEvent with _PointerEventDescription, ...@@ -2321,8 +2274,7 @@ class PointerPanZoomEndEvent extends PointerEvent with _PointerEventDescription,
} }
class _TransformedPointerPanZoomEndEvent extends _TransformedPointerEvent with _CopyPointerPanZoomEndEvent implements PointerPanZoomEndEvent { class _TransformedPointerPanZoomEndEvent extends _TransformedPointerEvent with _CopyPointerPanZoomEndEvent implements PointerPanZoomEndEvent {
_TransformedPointerPanZoomEndEvent(this.original, this.transform) _TransformedPointerPanZoomEndEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerPanZoomEndEvent original; final PointerPanZoomEndEvent original;
...@@ -2472,8 +2424,7 @@ double computeScaleSlop(PointerDeviceKind kind) { ...@@ -2472,8 +2424,7 @@ double computeScaleSlop(PointerDeviceKind kind) {
} }
class _TransformedPointerCancelEvent extends _TransformedPointerEvent with _CopyPointerCancelEvent implements PointerCancelEvent { class _TransformedPointerCancelEvent extends _TransformedPointerEvent with _CopyPointerCancelEvent implements PointerCancelEvent {
_TransformedPointerCancelEvent(this.original, this.transform) _TransformedPointerCancelEvent(this.original, this.transform);
: assert(original != null), assert(transform != null);
@override @override
final PointerCancelEvent original; final PointerCancelEvent original;
......
...@@ -52,9 +52,7 @@ class ForcePressDetails { ...@@ -52,9 +52,7 @@ class ForcePressDetails {
required this.globalPosition, required this.globalPosition,
Offset? localPosition, Offset? localPosition,
required this.pressure, required this.pressure,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
assert(pressure != null),
localPosition = localPosition ?? globalPosition;
/// The global position at which the function was called. /// The global position at which the function was called.
final Offset globalPosition; final Offset globalPosition;
...@@ -134,10 +132,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -134,10 +132,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
super.kind, super.kind,
super.supportedDevices, super.supportedDevices,
super.allowedButtonsFilter, super.allowedButtonsFilter,
}) : assert(startPressure != null), }) : assert(peakPressure > startPressure);
assert(peakPressure != null),
assert(interpolation != null),
assert(peakPressure > startPressure);
/// A pointer is in contact with the screen and has just pressed with a force /// A pointer is in contact with the screen and has just pressed with a force
/// exceeding the [startPressure]. Consequently, if there were other gesture /// exceeding the [startPressure]. Consequently, if there were other gesture
......
...@@ -215,7 +215,6 @@ class HitTestResult { ...@@ -215,7 +215,6 @@ class HitTestResult {
/// around this function for hit testing on [RenderBox]s. /// around this function for hit testing on [RenderBox]s.
@protected @protected
void pushTransform(Matrix4 transform) { void pushTransform(Matrix4 transform) {
assert(transform != null);
assert( assert(
_debugVectorMoreOrLessEquals(transform.getRow(2), Vector4(0, 0, 1, 0)) && _debugVectorMoreOrLessEquals(transform.getRow(2), Vector4(0, 0, 1, 0)) &&
_debugVectorMoreOrLessEquals(transform.getColumn(2), Vector4(0, 0, 1, 0)), _debugVectorMoreOrLessEquals(transform.getColumn(2), Vector4(0, 0, 1, 0)),
...@@ -255,7 +254,6 @@ class HitTestResult { ...@@ -255,7 +254,6 @@ class HitTestResult {
/// around this function for hit testing on [RenderSliver]s. /// around this function for hit testing on [RenderSliver]s.
@protected @protected
void pushOffset(Offset offset) { void pushOffset(Offset offset) {
assert(offset != null);
_localTransforms.add(_OffsetTransformPart(offset)); _localTransforms.add(_OffsetTransformPart(offset));
} }
......
...@@ -115,8 +115,7 @@ class LongPressDownDetails { ...@@ -115,8 +115,7 @@ class LongPressDownDetails {
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
this.kind, this.kind,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
final Offset globalPosition; final Offset globalPosition;
...@@ -142,8 +141,7 @@ class LongPressStartDetails { ...@@ -142,8 +141,7 @@ class LongPressStartDetails {
const LongPressStartDetails({ const LongPressStartDetails({
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer initially contacted the screen. /// The global position at which the pointer initially contacted the screen.
final Offset globalPosition; final Offset globalPosition;
...@@ -168,9 +166,7 @@ class LongPressMoveUpdateDetails { ...@@ -168,9 +166,7 @@ class LongPressMoveUpdateDetails {
Offset? localPosition, Offset? localPosition,
this.offsetFromOrigin = Offset.zero, this.offsetFromOrigin = Offset.zero,
Offset? localOffsetFromOrigin, Offset? localOffsetFromOrigin,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition,
assert(offsetFromOrigin != null),
localPosition = localPosition ?? globalPosition,
localOffsetFromOrigin = localOffsetFromOrigin ?? offsetFromOrigin; localOffsetFromOrigin = localOffsetFromOrigin ?? offsetFromOrigin;
/// The global position of the pointer when it triggered this update. /// The global position of the pointer when it triggered this update.
...@@ -205,8 +201,7 @@ class LongPressEndDetails { ...@@ -205,8 +201,7 @@ class LongPressEndDetails {
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
this.velocity = Velocity.zero, this.velocity = Velocity.zero,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer lifted from the screen. /// The global position at which the pointer lifted from the screen.
final Offset globalPosition; final Offset globalPosition;
......
...@@ -84,7 +84,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -84,7 +84,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
this.velocityTrackerBuilder = _defaultBuilder, this.velocityTrackerBuilder = _defaultBuilder,
super.supportedDevices, super.supportedDevices,
super.allowedButtonsFilter = _defaultButtonAcceptBehavior, super.allowedButtonsFilter = _defaultButtonAcceptBehavior,
}) : assert(dragStartBehavior != null); });
static VelocityTracker _defaultBuilder(PointerEvent event) => VelocityTracker.withKind(event.kind); static VelocityTracker _defaultBuilder(PointerEvent event) => VelocityTracker.withKind(event.kind);
...@@ -313,7 +313,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -313,7 +313,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
event is PointerPanZoomStartEvent || event is PointerPanZoomStartEvent ||
event is PointerPanZoomUpdateEvent)) { event is PointerPanZoomUpdateEvent)) {
final VelocityTracker tracker = _velocityTrackers[event.pointer]!; final VelocityTracker tracker = _velocityTrackers[event.pointer]!;
assert(tracker != null);
if (event is PointerPanZoomStartEvent) { if (event is PointerPanZoomStartEvent) {
tracker.addPosition(event.timeStamp, Offset.zero); tracker.addPosition(event.timeStamp, Offset.zero);
} else if (event is PointerPanZoomUpdateEvent) { } else if (event is PointerPanZoomUpdateEvent) {
...@@ -492,7 +491,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -492,7 +491,6 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer {
} }
final VelocityTracker tracker = _velocityTrackers[pointer]!; final VelocityTracker tracker = _velocityTrackers[pointer]!;
assert(tracker != null);
final DragEndDetails details; final DragEndDetails details;
final String Function() debugReport; final String Function() debugReport;
......
...@@ -35,8 +35,7 @@ abstract class MultiDragPointerState { ...@@ -35,8 +35,7 @@ abstract class MultiDragPointerState {
/// ///
/// The [initialPosition] argument must not be null. /// The [initialPosition] argument must not be null.
MultiDragPointerState(this.initialPosition, this.kind, this.gestureSettings) MultiDragPointerState(this.initialPosition, this.kind, this.gestureSettings)
: assert(initialPosition != null), : _velocityTracker = VelocityTracker.withKind(kind);
_velocityTracker = VelocityTracker.withKind(kind);
/// Device specific gesture configuration that should be preferred over /// Device specific gesture configuration that should be preferred over
/// framework constants. /// framework constants.
...@@ -133,7 +132,6 @@ abstract class MultiDragPointerState { ...@@ -133,7 +132,6 @@ abstract class MultiDragPointerState {
void _startDrag(Drag client) { void _startDrag(Drag client) {
assert(_arenaEntry != null); assert(_arenaEntry != null);
assert(_client == null); assert(_client == null);
assert(client != null);
assert(pendingDelta != null); assert(pendingDelta != null);
_client = client; _client = client;
final DragUpdateDetails details = DragUpdateDetails( final DragUpdateDetails details = DragUpdateDetails(
...@@ -240,8 +238,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer { ...@@ -240,8 +238,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
@override @override
void addAllowedPointer(PointerDownEvent event) { void addAllowedPointer(PointerDownEvent event) {
assert(_pointers != null); assert(_pointers != null);
assert(event.pointer != null);
assert(event.position != null);
assert(!_pointers!.containsKey(event.pointer)); assert(!_pointers!.containsKey(event.pointer));
final MultiDragPointerState state = createNewPointerState(event); final MultiDragPointerState state = createNewPointerState(event);
_pointers![event.pointer] = state; _pointers![event.pointer] = state;
...@@ -257,9 +253,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer { ...@@ -257,9 +253,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
void _handleEvent(PointerEvent event) { void _handleEvent(PointerEvent event) {
assert(_pointers != null); assert(_pointers != null);
assert(event.pointer != null);
assert(event.timeStamp != null);
assert(event.position != null);
assert(_pointers!.containsKey(event.pointer)); assert(_pointers!.containsKey(event.pointer));
final MultiDragPointerState state = _pointers![event.pointer]!; final MultiDragPointerState state = _pointers![event.pointer]!;
if (event is PointerMoveEvent) { if (event is PointerMoveEvent) {
...@@ -296,7 +289,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer { ...@@ -296,7 +289,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
Drag? _startDrag(Offset initialPosition, int pointer) { Drag? _startDrag(Offset initialPosition, int pointer) {
assert(_pointers != null); assert(_pointers != null);
final MultiDragPointerState state = _pointers![pointer]!; final MultiDragPointerState state = _pointers![pointer]!;
assert(state != null);
assert(state._pendingDelta != null); assert(state._pendingDelta != null);
Drag? drag; Drag? drag;
if (onStart != null) { if (onStart != null) {
...@@ -315,7 +307,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer { ...@@ -315,7 +307,6 @@ abstract class MultiDragGestureRecognizer extends GestureRecognizer {
assert(_pointers != null); assert(_pointers != null);
if (_pointers!.containsKey(pointer)) { if (_pointers!.containsKey(pointer)) {
final MultiDragPointerState state = _pointers![pointer]!; final MultiDragPointerState state = _pointers![pointer]!;
assert(state != null);
state.rejected(); state.rejected();
_removeState(pointer); _removeState(pointer);
} // else we already preemptively forgot about it (e.g. we got an up event) } // else we already preemptively forgot about it (e.g. we got an up event)
...@@ -515,8 +506,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer { ...@@ -515,8 +506,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
} }
class _DelayedPointerState extends MultiDragPointerState { class _DelayedPointerState extends MultiDragPointerState {
_DelayedPointerState(super.initialPosition, Duration delay, super.kind, super.deviceGestureSettings) _DelayedPointerState(super.initialPosition, Duration delay, super.kind, super.deviceGestureSettings) {
: assert(delay != null) {
_timer = Timer(delay, _delayPassed); _timer = Timer(delay, _delayPassed);
} }
...@@ -614,7 +604,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer { ...@@ -614,7 +604,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer {
super.kind, super.kind,
super.supportedDevices, super.supportedDevices,
super.allowedButtonsFilter, super.allowedButtonsFilter,
}) : assert(delay != null); });
/// The amount of time the pointer must remain in the same place for the drag /// The amount of time the pointer must remain in the same place for the drag
/// to be recognized. /// to be recognized.
......
...@@ -43,8 +43,7 @@ typedef GestureMultiTapCancelCallback = void Function(int pointer); ...@@ -43,8 +43,7 @@ typedef GestureMultiTapCancelCallback = void Function(int pointer);
/// CountdownZoned tracks whether the specified duration has elapsed since /// CountdownZoned tracks whether the specified duration has elapsed since
/// creation, honoring [Zone]. /// creation, honoring [Zone].
class _CountdownZoned { class _CountdownZoned {
_CountdownZoned({ required Duration duration }) _CountdownZoned({ required Duration duration }) {
: assert(duration != null) {
Timer(duration, _onTimeout); Timer(duration, _onTimeout);
} }
...@@ -65,10 +64,7 @@ class _TapTracker { ...@@ -65,10 +64,7 @@ class _TapTracker {
required this.entry, required this.entry,
required Duration doubleTapMinTime, required Duration doubleTapMinTime,
required this.gestureSettings, required this.gestureSettings,
}) : assert(doubleTapMinTime != null), }) : pointer = event.pointer,
assert(event != null),
assert(event.buttons != null),
pointer = event.pointer,
_initialGlobalPosition = event.position, _initialGlobalPosition = event.position,
initialButtons = event.buttons, initialButtons = event.buttons,
_doubleTapMinTimeCountdown = _CountdownZoned(duration: doubleTapMinTime); _doubleTapMinTimeCountdown = _CountdownZoned(duration: doubleTapMinTime);
...@@ -684,8 +680,7 @@ class SerialTapCancelDetails { ...@@ -684,8 +680,7 @@ class SerialTapCancelDetails {
/// The `count` argument must be greater than zero. /// The `count` argument must be greater than zero.
SerialTapCancelDetails({ SerialTapCancelDetails({
this.count = 1, this.count = 1,
}) : assert(count != null), }) : assert(count > 0);
assert(count > 0);
/// The number of consecutive taps that were in progress when the gesture was /// The number of consecutive taps that were in progress when the gesture was
/// interrupted. /// interrupted.
......
...@@ -64,8 +64,6 @@ class PointerSignalResolver { ...@@ -64,8 +64,6 @@ class PointerSignalResolver {
/// See the documentation for the [PointerSignalResolver] class on when and /// See the documentation for the [PointerSignalResolver] class on when and
/// how this method should be used. /// how this method should be used.
void register(PointerSignalEvent event, PointerSignalResolvedCallback callback) { void register(PointerSignalEvent event, PointerSignalResolvedCallback callback) {
assert(event != null);
assert(callback != null);
assert(_currentEvent == null || _isSameEvent(_currentEvent!, event)); assert(_currentEvent == null || _isSameEvent(_currentEvent!, event));
if (_firstRegisteredCallback != null) { if (_firstRegisteredCallback != null) {
return; return;
......
...@@ -267,7 +267,6 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT ...@@ -267,7 +267,6 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT
@protected @protected
@pragma('vm:notify-debugger-on-exception') @pragma('vm:notify-debugger-on-exception')
T? invokeCallback<T>(String name, RecognizerCallback<T> callback, { String Function()? debugReport }) { T? invokeCallback<T>(String name, RecognizerCallback<T> callback, { String Function()? debugReport }) {
assert(callback != null);
T? result; T? result;
try { try {
assert(() { assert(() {
......
...@@ -102,7 +102,7 @@ class ScaleStartDetails { ...@@ -102,7 +102,7 @@ class ScaleStartDetails {
this.focalPoint = Offset.zero, this.focalPoint = Offset.zero,
Offset? localFocalPoint, Offset? localFocalPoint,
this.pointerCount = 0, this.pointerCount = 0,
}) : assert(focalPoint != null), localFocalPoint = localFocalPoint ?? focalPoint; }) : localFocalPoint = localFocalPoint ?? focalPoint;
/// The initial focal point of the pointers in contact with the screen. /// The initial focal point of the pointers in contact with the screen.
/// ///
...@@ -151,12 +151,9 @@ class ScaleUpdateDetails { ...@@ -151,12 +151,9 @@ class ScaleUpdateDetails {
this.rotation = 0.0, this.rotation = 0.0,
this.pointerCount = 0, this.pointerCount = 0,
this.focalPointDelta = Offset.zero, this.focalPointDelta = Offset.zero,
}) : assert(focalPoint != null), }) : assert(scale >= 0.0),
assert(focalPointDelta != null), assert(horizontalScale >= 0.0),
assert(scale != null && scale >= 0.0), assert(verticalScale >= 0.0),
assert(horizontalScale != null && horizontalScale >= 0.0),
assert(verticalScale != null && verticalScale >= 0.0),
assert(rotation != null),
localFocalPoint = localFocalPoint ?? focalPoint; localFocalPoint = localFocalPoint ?? focalPoint;
/// The amount the gesture's focal point has moved in the coordinate space of /// The amount the gesture's focal point has moved in the coordinate space of
...@@ -248,8 +245,7 @@ class ScaleEndDetails { ...@@ -248,8 +245,7 @@ class ScaleEndDetails {
/// Creates details for [GestureScaleEndCallback]. /// Creates details for [GestureScaleEndCallback].
/// ///
/// The [velocity] argument must not be null. /// The [velocity] argument must not be null.
ScaleEndDetails({ this.velocity = Velocity.zero, this.scaleVelocity = 0, this.pointerCount = 0 }) ScaleEndDetails({ this.velocity = Velocity.zero, this.scaleVelocity = 0, this.pointerCount = 0 });
: assert(velocity != null);
/// The velocity of the last pointer to be lifted off of the screen. /// The velocity of the last pointer to be lifted off of the screen.
final Velocity velocity; final Velocity velocity;
...@@ -279,7 +275,6 @@ typedef GestureScaleUpdateCallback = void Function(ScaleUpdateDetails details); ...@@ -279,7 +275,6 @@ typedef GestureScaleUpdateCallback = void Function(ScaleUpdateDetails details);
typedef GestureScaleEndCallback = void Function(ScaleEndDetails details); typedef GestureScaleEndCallback = void Function(ScaleEndDetails details);
bool _isFlingGesture(Velocity velocity) { bool _isFlingGesture(Velocity velocity) {
assert(velocity != null);
final double speedSquared = velocity.pixelsPerSecond.distanceSquared; final double speedSquared = velocity.pixelsPerSecond.distanceSquared;
return speedSquared > kMinFlingVelocity * kMinFlingVelocity; return speedSquared > kMinFlingVelocity * kMinFlingVelocity;
} }
...@@ -299,9 +294,7 @@ class _LineBetweenPointers { ...@@ -299,9 +294,7 @@ class _LineBetweenPointers {
this.pointerStartId = 0, this.pointerStartId = 0,
this.pointerEndLocation = Offset.zero, this.pointerEndLocation = Offset.zero,
this.pointerEndId = 1, this.pointerEndId = 1,
}) : assert(pointerStartLocation != null && pointerEndLocation != null), }) : assert(pointerStartId != pointerEndId);
assert(pointerStartId != null && pointerEndId != null),
assert(pointerStartId != pointerEndId);
// The location and the id of the pointer that marks the start of the line. // The location and the id of the pointer that marks the start of the line.
final Offset pointerStartLocation; final Offset pointerStartLocation;
...@@ -338,7 +331,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { ...@@ -338,7 +331,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer {
this.dragStartBehavior = DragStartBehavior.down, this.dragStartBehavior = DragStartBehavior.down,
this.trackpadScrollCausesScale = false, this.trackpadScrollCausesScale = false,
this.trackpadScrollToScaleFactor = kDefaultTrackpadScrollToScaleFactor, this.trackpadScrollToScaleFactor = kDefaultTrackpadScrollToScaleFactor,
}) : assert(dragStartBehavior != null); });
/// Determines what point is used as the starting point in all calculations /// Determines what point is used as the starting point in all calculations
/// involving this gesture. /// involving this gesture.
......
...@@ -32,8 +32,7 @@ class TapDownDetails { ...@@ -32,8 +32,7 @@ class TapDownDetails {
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
this.kind, this.kind,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
final Offset globalPosition; final Offset globalPosition;
...@@ -71,8 +70,7 @@ class TapUpDetails { ...@@ -71,8 +70,7 @@ class TapUpDetails {
required this.kind, required this.kind,
this.globalPosition = Offset.zero, this.globalPosition = Offset.zero,
Offset? localPosition, Offset? localPosition,
}) : assert(globalPosition != null), }) : localPosition = localPosition ?? globalPosition;
localPosition = localPosition ?? globalPosition;
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
final Offset globalPosition; final Offset globalPosition;
...@@ -206,7 +204,6 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer ...@@ -206,7 +204,6 @@ abstract class BaseTapGestureRecognizer extends PrimaryPointerGestureRecognizer
@override @override
void addAllowedPointer(PointerDownEvent event) { void addAllowedPointer(PointerDownEvent event) {
assert(event != null);
if (state == GestureRecognizerState.ready) { if (state == GestureRecognizerState.ready) {
// If there is no result in the previous gesture arena, // If there is no result in the previous gesture arena,
// we ignore them and prepare to accept a new pointer. // we ignore them and prepare to accept a new pointer.
......
...@@ -18,7 +18,7 @@ class Velocity { ...@@ -18,7 +18,7 @@ class Velocity {
/// The [pixelsPerSecond] argument must not be null. /// The [pixelsPerSecond] argument must not be null.
const Velocity({ const Velocity({
required this.pixelsPerSecond, required this.pixelsPerSecond,
}) : assert(pixelsPerSecond != null); });
/// A velocity that isn't moving at all. /// A velocity that isn't moving at all.
static const Velocity zero = Velocity(pixelsPerSecond: Offset.zero); static const Velocity zero = Velocity(pixelsPerSecond: Offset.zero);
...@@ -50,8 +50,8 @@ class Velocity { ...@@ -50,8 +50,8 @@ class Velocity {
/// If the magnitude of this Velocity is within the specified bounds then /// If the magnitude of this Velocity is within the specified bounds then
/// just return this. /// just return this.
Velocity clampMagnitude(double minValue, double maxValue) { Velocity clampMagnitude(double minValue, double maxValue) {
assert(minValue != null && minValue >= 0.0); assert(minValue >= 0.0);
assert(maxValue != null && maxValue >= 0.0 && maxValue >= minValue); assert(maxValue >= 0.0 && maxValue >= minValue);
final double valueSquared = pixelsPerSecond.distanceSquared; final double valueSquared = pixelsPerSecond.distanceSquared;
if (valueSquared > maxValue * maxValue) { if (valueSquared > maxValue * maxValue) {
return Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * maxValue); return Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * maxValue);
...@@ -97,10 +97,7 @@ class VelocityEstimate { ...@@ -97,10 +97,7 @@ class VelocityEstimate {
required this.confidence, required this.confidence,
required this.duration, required this.duration,
required this.offset, required this.offset,
}) : assert(pixelsPerSecond != null), });
assert(confidence != null),
assert(duration != null),
assert(offset != null);
/// The number of pixels per second of velocity in the x and y directions. /// The number of pixels per second of velocity in the x and y directions.
final Offset pixelsPerSecond; final Offset pixelsPerSecond;
...@@ -124,9 +121,7 @@ class VelocityEstimate { ...@@ -124,9 +121,7 @@ class VelocityEstimate {
} }
class _PointAtTime { class _PointAtTime {
const _PointAtTime(this.point, this.time) const _PointAtTime(this.point, this.time);
: assert(point != null),
assert(time != null);
final Duration time; final Duration time;
final Offset point; final Offset point;
......
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