Commit c63be2af authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

apply prefer_asserts_in_initializer_list lint (#10483)

parent 69e23538
...@@ -115,12 +115,11 @@ class AnimationController extends Animation<double> ...@@ -115,12 +115,11 @@ class AnimationController extends Animation<double>
this.lowerBound: 0.0, this.lowerBound: 0.0,
this.upperBound: 1.0, this.upperBound: 1.0,
@required TickerProvider vsync, @required TickerProvider vsync,
}) { }) : assert(lowerBound != null),
assert(lowerBound != null); assert(upperBound != null),
assert(upperBound != null); assert(upperBound >= lowerBound),
assert(upperBound >= lowerBound); assert(vsync != null),
assert(vsync != null); _direction = _AnimationDirection.forward {
_direction = _AnimationDirection.forward;
_ticker = vsync.createTicker(_tick); _ticker = vsync.createTicker(_tick);
_internalSetValue(value ?? lowerBound); _internalSetValue(value ?? lowerBound);
} }
...@@ -146,11 +145,11 @@ class AnimationController extends Animation<double> ...@@ -146,11 +145,11 @@ class AnimationController extends Animation<double>
this.duration, this.duration,
this.debugLabel, this.debugLabel,
@required TickerProvider vsync, @required TickerProvider vsync,
}) : lowerBound = double.NEGATIVE_INFINITY, }) : assert(value != null),
upperBound = double.INFINITY { assert(vsync != null),
assert(value != null); lowerBound = double.NEGATIVE_INFINITY,
assert(vsync != null); upperBound = double.INFINITY,
_direction = _AnimationDirection.forward; _direction = _AnimationDirection.forward {
_ticker = vsync.createTicker(_tick); _ticker = vsync.createTicker(_tick);
_internalSetValue(value); _internalSetValue(value);
} }
...@@ -496,11 +495,10 @@ class AnimationController extends Animation<double> ...@@ -496,11 +495,10 @@ class AnimationController extends Animation<double>
class _InterpolationSimulation extends Simulation { class _InterpolationSimulation extends Simulation {
_InterpolationSimulation(this._begin, this._end, Duration duration, this._curve) _InterpolationSimulation(this._begin, this._end, Duration duration, this._curve)
: _durationInSeconds = duration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND { : assert(_begin != null),
assert(_durationInSeconds > 0.0); assert(_end != null),
assert(_begin != null); assert(duration != null && duration.inMicroseconds > 0),
assert(_end != null); _durationInSeconds = duration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND;
}
final double _durationInSeconds; final double _durationInSeconds;
final double _begin; final double _begin;
......
...@@ -247,9 +247,8 @@ class ReverseAnimation extends Animation<double> ...@@ -247,9 +247,8 @@ class ReverseAnimation extends Animation<double>
/// Creates a reverse animation. /// Creates a reverse animation.
/// ///
/// The parent argument must not be null. /// The parent argument must not be null.
ReverseAnimation(this.parent) { ReverseAnimation(this.parent)
assert(parent != null); : assert(parent != null);
}
/// The animation whose value and direction this animation is reversing. /// The animation whose value and direction this animation is reversing.
final Animation<double> parent; final Animation<double> parent;
...@@ -331,9 +330,8 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do ...@@ -331,9 +330,8 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
@required this.parent, @required this.parent,
@required this.curve, @required this.curve,
this.reverseCurve this.reverseCurve
}) { }) : assert(parent != null),
assert(parent != null); assert(curve != null) {
assert(curve != null);
_updateCurveDirection(parent.status); _updateCurveDirection(parent.status);
parent.addStatusListener(_updateCurveDirection); parent.addStatusListener(_updateCurveDirection);
} }
...@@ -441,8 +439,8 @@ class TrainHoppingAnimation extends Animation<double> ...@@ -441,8 +439,8 @@ class TrainHoppingAnimation extends Animation<double>
/// ///
/// The current train argument must not be null but the next train argument /// The current train argument must not be null but the next train argument
/// can be null. /// can be null.
TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain }) { TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain })
assert(_currentTrain != null); : assert(_currentTrain != null) {
if (_nextTrain != null) { if (_nextTrain != null) {
if (_currentTrain.value > _nextTrain.value) { if (_currentTrain.value > _nextTrain.value) {
_mode = _TrainHoppingMode.maximize; _mode = _TrainHoppingMode.maximize;
...@@ -552,10 +550,8 @@ abstract class CompoundAnimation<T> extends Animation<T> ...@@ -552,10 +550,8 @@ abstract class CompoundAnimation<T> extends Animation<T>
CompoundAnimation({ CompoundAnimation({
@required this.first, @required this.first,
@required this.next, @required this.next,
}) { }) : assert(first != null),
assert(first != null);
assert(next != null); assert(next != null);
}
/// The first sub-animation. Its status takes precedence if neither are /// The first sub-animation. Its status takes precedence if neither are
/// animating. /// animating.
......
...@@ -291,9 +291,8 @@ class CurveTween extends Animatable<double> { ...@@ -291,9 +291,8 @@ class CurveTween extends Animatable<double> {
/// Creates a curve tween. /// Creates a curve tween.
/// ///
/// The [curve] argument must not be null. /// The [curve] argument must not be null.
CurveTween({ @required this.curve }) { CurveTween({ @required this.curve })
assert(curve != null); : assert(curve != null);
}
/// The curve to use when transforming the value of the animation. /// The curve to use when transforming the value of the animation.
Curve curve; Curve curve;
......
...@@ -41,12 +41,11 @@ class CupertinoTabBar extends StatelessWidget { ...@@ -41,12 +41,11 @@ class CupertinoTabBar extends StatelessWidget {
this.activeColor: CupertinoColors.activeBlue, this.activeColor: CupertinoColors.activeBlue,
this.inactiveColor: CupertinoColors.inactiveGray, this.inactiveColor: CupertinoColors.inactiveGray,
this.iconSize: 24.0, this.iconSize: 24.0,
}) : super(key: key) { }) : assert(items != null),
assert(items != null); assert(items.length >= 2),
assert(items.length >= 2); assert(0 <= currentIndex && currentIndex < items.length),
assert(0 <= currentIndex && currentIndex < items.length); assert(iconSize != null),
assert(iconSize != null); super(key: key);
}
/// The interactive items laid out within the bottom navigation bar. /// The interactive items laid out within the bottom navigation bar.
final List<BottomNavigationBarItem> items; final List<BottomNavigationBarItem> items;
......
...@@ -249,9 +249,8 @@ class CupertinoBackGestureController extends NavigationGestureController { ...@@ -249,9 +249,8 @@ class CupertinoBackGestureController extends NavigationGestureController {
CupertinoBackGestureController({ CupertinoBackGestureController({
@required NavigatorState navigator, @required NavigatorState navigator,
@required this.controller, @required this.controller,
}) : super(navigator) { }) : assert(controller != null),
assert(controller != null); super(navigator);
}
/// The animation controller that the route uses to drive its transition /// The animation controller that the route uses to drive its transition
/// animation. /// animation.
......
...@@ -192,11 +192,11 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc ...@@ -192,11 +192,11 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
Color activeColor, Color activeColor,
this.onChanged, this.onChanged,
TickerProvider vsync, TickerProvider vsync,
}) : _value = value, }) : assert(value != null && value >= 0.0 && value <= 1.0),
_value = value,
_divisions = divisions, _divisions = divisions,
_activeColor = activeColor, _activeColor = activeColor,
super(additionalConstraints: const BoxConstraints.tightFor(width: _kSliderWidth, height: _kSliderHeight)) { super(additionalConstraints: const BoxConstraints.tightFor(width: _kSliderWidth, height: _kSliderHeight)) {
assert(value != null && value >= 0.0 && value <= 1.0);
_drag = new HorizontalDragGestureRecognizer() _drag = new HorizontalDragGestureRecognizer()
..onStart = _handleDragStart ..onStart = _handleDragStart
..onUpdate = _handleDragUpdate ..onUpdate = _handleDragUpdate
......
...@@ -141,14 +141,14 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc ...@@ -141,14 +141,14 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc
@required Color activeColor, @required Color activeColor,
ValueChanged<bool> onChanged, ValueChanged<bool> onChanged,
@required TickerProvider vsync, @required TickerProvider vsync,
}) : _value = value, }) : assert(value != null),
assert(activeColor != null),
assert(vsync != null),
_value = value,
_activeColor = activeColor, _activeColor = activeColor,
_onChanged = onChanged, _onChanged = onChanged,
_vsync = vsync, _vsync = vsync,
super(additionalConstraints: const BoxConstraints.tightFor(width: _kSwitchWidth, height: _kSwitchHeight)) { super(additionalConstraints: const BoxConstraints.tightFor(width: _kSwitchWidth, height: _kSwitchHeight)) {
assert(value != null);
assert(activeColor != null);
assert(vsync != null);
_tap = new TapGestureRecognizer() _tap = new TapGestureRecognizer()
..onTapDown = _handleTapDown ..onTapDown = _handleTapDown
..onTap = _handleTap ..onTap = _handleTap
......
...@@ -20,9 +20,8 @@ class DragDownDetails { ...@@ -20,9 +20,8 @@ class DragDownDetails {
/// Creates details for a [GestureDragDownCallback]. /// Creates details for a [GestureDragDownCallback].
/// ///
/// The [globalPosition] argument must not be null. /// The [globalPosition] argument must not be null.
DragDownDetails({ this.globalPosition: Offset.zero }) { DragDownDetails({ this.globalPosition: Offset.zero })
assert(globalPosition != null); : assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
/// ///
...@@ -53,9 +52,8 @@ class DragStartDetails { ...@@ -53,9 +52,8 @@ class DragStartDetails {
/// Creates details for a [GestureDragStartCallback]. /// Creates details for a [GestureDragStartCallback].
/// ///
/// The [globalPosition] argument must not be null. /// The [globalPosition] argument must not be null.
DragStartDetails({ this.globalPosition: Offset.zero }) { DragStartDetails({ this.globalPosition: Offset.zero })
assert(globalPosition != null); : assert(globalPosition != null);
}
/// The global position at which the pointer contacted the screen. /// The global position at which the pointer contacted the screen.
/// ///
...@@ -99,12 +97,10 @@ class DragUpdateDetails { ...@@ -99,12 +97,10 @@ class DragUpdateDetails {
this.delta: Offset.zero, this.delta: Offset.zero,
this.primaryDelta, this.primaryDelta,
@required this.globalPosition @required this.globalPosition
}) { }) : assert(delta != null),
assert(delta != null);
assert(primaryDelta == null assert(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));
}
/// The amount the pointer has moved since the previous update. /// The amount the pointer has moved since the previous update.
/// ///
...@@ -158,12 +154,10 @@ class DragEndDetails { ...@@ -158,12 +154,10 @@ class DragEndDetails {
DragEndDetails({ DragEndDetails({
this.velocity: Velocity.zero, this.velocity: Velocity.zero,
this.primaryVelocity, this.primaryVelocity,
}) { }) : assert(velocity != null),
assert(velocity != null);
assert(primaryVelocity == null assert(primaryVelocity == null
|| primaryVelocity == velocity.pixelsPerSecond.dx || primaryVelocity == velocity.pixelsPerSecond.dx
|| primaryVelocity == velocity.pixelsPerSecond.dy); || primaryVelocity == velocity.pixelsPerSecond.dy);
}
/// The velocity the pointer was moving when it stopped contacting the screen. /// The velocity the pointer was moving when it stopped contacting the screen.
/// ///
......
...@@ -75,10 +75,9 @@ class LeastSquaresSolver { ...@@ -75,10 +75,9 @@ class LeastSquaresSolver {
/// Creates a least-squares solver. /// Creates a least-squares solver.
/// ///
/// The [x], [y], and [w] arguments must not be null. /// The [x], [y], and [w] arguments must not be null.
LeastSquaresSolver(this.x, this.y, this.w) { LeastSquaresSolver(this.x, this.y, this.w)
assert(x.length == y.length); : assert(x.length == y.length),
assert(y.length == w.length); assert(y.length == w.length);
}
/// The x-coordinates of each data point. /// The x-coordinates of each data point.
final List<double> x; final List<double> x;
......
...@@ -27,9 +27,8 @@ abstract class MultiDragPointerState { ...@@ -27,9 +27,8 @@ abstract class MultiDragPointerState {
/// Creates per-pointer state for a [MultiDragGestureRecognizer]. /// Creates per-pointer state for a [MultiDragGestureRecognizer].
/// ///
/// The [initialPosition] argument must not be null. /// The [initialPosition] argument must not be null.
MultiDragPointerState(this.initialPosition) { MultiDragPointerState(this.initialPosition)
assert(initialPosition != null); : assert(initialPosition != null);
}
/// The global coordinates of the pointer when the pointer contacted the screen. /// The global coordinates of the pointer when the pointer contacted the screen.
final Offset initialPosition; final Offset initialPosition;
...@@ -396,8 +395,9 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver ...@@ -396,8 +395,9 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver
} }
class _DelayedPointerState extends MultiDragPointerState { class _DelayedPointerState extends MultiDragPointerState {
_DelayedPointerState(Offset initialPosition, Duration delay) : super(initialPosition) { _DelayedPointerState(Offset initialPosition, Duration delay)
assert(delay != null); : assert(delay != null),
super(initialPosition) {
_timer = new Timer(delay, _delayPassed); _timer = new Timer(delay, _delayPassed);
} }
...@@ -481,9 +481,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela ...@@ -481,9 +481,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela
/// can be changed for specific behaviors. /// can be changed for specific behaviors.
DelayedMultiDragGestureRecognizer({ DelayedMultiDragGestureRecognizer({
this.delay: kLongPressTimeout this.delay: kLongPressTimeout
}) { }) : assert(delay != null);
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.
......
...@@ -32,9 +32,8 @@ class ScaleStartDetails { ...@@ -32,9 +32,8 @@ class ScaleStartDetails {
/// Creates details for [GestureScaleStartCallback]. /// Creates details for [GestureScaleStartCallback].
/// ///
/// The [focalPoint] argument must not be null. /// The [focalPoint] argument must not be null.
ScaleStartDetails({ this.focalPoint: Offset.zero }) { ScaleStartDetails({ this.focalPoint: Offset.zero })
assert(focalPoint != null); : assert(focalPoint != null);
}
/// The initial focal point of the pointers in contact with the screen. /// The initial focal point of the pointers in contact with the screen.
/// Reported in global coordinates. /// Reported in global coordinates.
...@@ -50,10 +49,11 @@ class ScaleUpdateDetails { ...@@ -50,10 +49,11 @@ class ScaleUpdateDetails {
/// ///
/// The [focalPoint] and [scale] arguments must not be null. The [scale] /// The [focalPoint] and [scale] arguments must not be null. The [scale]
/// argument must be greater than or equal to zero. /// argument must be greater than or equal to zero.
ScaleUpdateDetails({ this.focalPoint: Offset.zero, this.scale: 1.0 }) { ScaleUpdateDetails({
assert(focalPoint != null); this.focalPoint: Offset.zero,
this.scale: 1.0,
}) : assert(focalPoint != null),
assert(scale != null && scale >= 0.0); assert(scale != null && scale >= 0.0);
}
/// The focal point of the pointers in contact with the screen. Reported in /// The focal point of the pointers in contact with the screen. Reported in
/// global coordinates. /// global coordinates.
...@@ -72,9 +72,8 @@ class ScaleEndDetails { ...@@ -72,9 +72,8 @@ 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 }) { ScaleEndDetails({ this.velocity: Velocity.zero })
assert(velocity != null); : 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;
......
...@@ -12,9 +12,8 @@ class TapDownDetails { ...@@ -12,9 +12,8 @@ class TapDownDetails {
/// Creates details for a [GestureTapDownCallback]. /// Creates details for a [GestureTapDownCallback].
/// ///
/// The [globalPosition] argument must not be null. /// The [globalPosition] argument must not be null.
TapDownDetails({ this.globalPosition: Offset.zero }) { TapDownDetails({ this.globalPosition: Offset.zero })
assert(globalPosition != null); : assert(globalPosition != null);
}
/// 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;
...@@ -32,9 +31,8 @@ class TapUpDetails { ...@@ -32,9 +31,8 @@ class TapUpDetails {
/// Creates details for a [GestureTapUpCallback]. /// Creates details for a [GestureTapUpCallback].
/// ///
/// The [globalPosition] argument must not be null. /// The [globalPosition] argument must not be null.
TapUpDetails({ this.globalPosition: Offset.zero }) { TapUpDetails({ this.globalPosition: Offset.zero })
assert(globalPosition != null); : assert(globalPosition != null);
}
/// 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;
......
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