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