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>
this.lowerBound: 0.0,
this.upperBound: 1.0,
@required TickerProvider vsync,
}) {
assert(lowerBound != null);
assert(upperBound != null);
assert(upperBound >= lowerBound);
assert(vsync != null);
_direction = _AnimationDirection.forward;
}) : assert(lowerBound != null),
assert(upperBound != null),
assert(upperBound >= lowerBound),
assert(vsync != null),
_direction = _AnimationDirection.forward {
_ticker = vsync.createTicker(_tick);
_internalSetValue(value ?? lowerBound);
}
......@@ -146,11 +145,11 @@ class AnimationController extends Animation<double>
this.duration,
this.debugLabel,
@required TickerProvider vsync,
}) : lowerBound = double.NEGATIVE_INFINITY,
upperBound = double.INFINITY {
assert(value != null);
assert(vsync != null);
_direction = _AnimationDirection.forward;
}) : assert(value != null),
assert(vsync != null),
lowerBound = double.NEGATIVE_INFINITY,
upperBound = double.INFINITY,
_direction = _AnimationDirection.forward {
_ticker = vsync.createTicker(_tick);
_internalSetValue(value);
}
......@@ -496,11 +495,10 @@ class AnimationController extends Animation<double>
class _InterpolationSimulation extends Simulation {
_InterpolationSimulation(this._begin, this._end, Duration duration, this._curve)
: _durationInSeconds = duration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND {
assert(_durationInSeconds > 0.0);
assert(_begin != null);
assert(_end != null);
}
: assert(_begin != null),
assert(_end != null),
assert(duration != null && duration.inMicroseconds > 0),
_durationInSeconds = duration.inMicroseconds / Duration.MICROSECONDS_PER_SECOND;
final double _durationInSeconds;
final double _begin;
......
......@@ -247,9 +247,8 @@ class ReverseAnimation extends Animation<double>
/// Creates a reverse animation.
///
/// The parent argument must not be null.
ReverseAnimation(this.parent) {
assert(parent != null);
}
ReverseAnimation(this.parent)
: assert(parent != null);
/// The animation whose value and direction this animation is reversing.
final Animation<double> parent;
......@@ -331,9 +330,8 @@ class CurvedAnimation extends Animation<double> with AnimationWithParentMixin<do
@required this.parent,
@required this.curve,
this.reverseCurve
}) {
assert(parent != null);
assert(curve != null);
}) : assert(parent != null),
assert(curve != null) {
_updateCurveDirection(parent.status);
parent.addStatusListener(_updateCurveDirection);
}
......@@ -441,8 +439,8 @@ class TrainHoppingAnimation extends Animation<double>
///
/// The current train argument must not be null but the next train argument
/// can be null.
TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain }) {
assert(_currentTrain != null);
TrainHoppingAnimation(this._currentTrain, this._nextTrain, { this.onSwitchedTrain })
: assert(_currentTrain != null) {
if (_nextTrain != null) {
if (_currentTrain.value > _nextTrain.value) {
_mode = _TrainHoppingMode.maximize;
......@@ -552,10 +550,8 @@ abstract class CompoundAnimation<T> extends Animation<T>
CompoundAnimation({
@required this.first,
@required this.next,
}) {
assert(first != null);
assert(next != null);
}
}) : assert(first != null),
assert(next != null);
/// The first sub-animation. Its status takes precedence if neither are
/// animating.
......
......@@ -291,9 +291,8 @@ class CurveTween extends Animatable<double> {
/// Creates a curve tween.
///
/// The [curve] argument must not be null.
CurveTween({ @required this.curve }) {
assert(curve != null);
}
CurveTween({ @required this.curve })
: assert(curve != null);
/// The curve to use when transforming the value of the animation.
Curve curve;
......
......@@ -41,12 +41,11 @@ class CupertinoTabBar extends StatelessWidget {
this.activeColor: CupertinoColors.activeBlue,
this.inactiveColor: CupertinoColors.inactiveGray,
this.iconSize: 24.0,
}) : super(key: key) {
assert(items != null);
assert(items.length >= 2);
assert(0 <= currentIndex && currentIndex < items.length);
assert(iconSize != null);
}
}) : assert(items != null),
assert(items.length >= 2),
assert(0 <= currentIndex && currentIndex < items.length),
assert(iconSize != null),
super(key: key);
/// The interactive items laid out within the bottom navigation bar.
final List<BottomNavigationBarItem> items;
......
......@@ -25,7 +25,7 @@ final FractionalOffsetTween _kBottomUpTween = new FractionalOffsetTween(
end: FractionalOffset.topLeft,
);
// Custom decoration from no shadow to page shadow mimicking iOS page
// Custom decoration from no shadow to page shadow mimicking iOS page
// transitions using gradients.
final DecorationTween _kGradientShadowTween = new DecorationTween(
begin: _CupertinoEdgeShadowDecoration.none, // No decoration initially.
......@@ -36,27 +36,27 @@ final DecorationTween _kGradientShadowTween = new DecorationTween(
end: FractionalOffset.topRight,
// Eyeballed gradient used to mimic a drop shadow on the left side only.
colors: const <Color>[
const Color(0x00000000),
const Color(0x00000000),
const Color(0x04000000),
const Color(0x12000000),
const Color(0x38000000)
],
stops: const <double>[0.0, 0.3, 0.6, 1.0],
),
),
),
);
/// A custom [Decoration] used to paint an extra shadow on the left edge of the
/// box it's decorating. It's like a [BoxDecoration] with only a gradient except
/// A custom [Decoration] used to paint an extra shadow on the left edge of the
/// box it's decorating. It's like a [BoxDecoration] with only a gradient except
/// it paints to the left of the box instead of behind the box.
class _CupertinoEdgeShadowDecoration extends Decoration {
const _CupertinoEdgeShadowDecoration({ this.edgeGradient });
/// A Decoration with no decorating properties.
static const _CupertinoEdgeShadowDecoration none =
static const _CupertinoEdgeShadowDecoration none =
const _CupertinoEdgeShadowDecoration();
/// A gradient to draw to the left of the box being decorated.
/// A gradient to draw to the left of the box being decorated.
/// FractionalOffsets are relative to the original box translated one box
/// width to the left.
final LinearGradient edgeGradient;
......@@ -65,8 +65,8 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
///
/// See also [Decoration.lerp].
static _CupertinoEdgeShadowDecoration lerp(
_CupertinoEdgeShadowDecoration a,
_CupertinoEdgeShadowDecoration b,
_CupertinoEdgeShadowDecoration a,
_CupertinoEdgeShadowDecoration b,
double t
) {
if (a == null && b == null)
......@@ -89,7 +89,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
return _CupertinoEdgeShadowDecoration.lerp(this, null, t);
return _CupertinoEdgeShadowDecoration.lerp(this, b, t);
}
@override
_CupertinoEdgeShadowPainter createBoxPainter([VoidCallback onChanged]) {
return new _CupertinoEdgeShadowPainter(this, onChanged);
......@@ -114,7 +114,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration {
/// A [BoxPainter] used to draw the page transition shadow using gradients.
class _CupertinoEdgeShadowPainter extends BoxPainter {
_CupertinoEdgeShadowPainter(
@required this._decoration,
@required this._decoration,
VoidCallback onChange
) : assert(_decoration != null),
super(onChange);
......@@ -126,9 +126,9 @@ class _CupertinoEdgeShadowPainter extends BoxPainter {
final LinearGradient gradient = _decoration.edgeGradient;
if (gradient == null)
return;
// The drawable space for the gradient is a rect with the same size as
// The drawable space for the gradient is a rect with the same size as
// its parent box one box width to the left of the box.
final Rect rect =
final Rect rect =
(offset & configuration.size).translate(-configuration.size.width, 0.0);
final Paint paint = new Paint()
..shader = gradient.createShader(rect);
......@@ -249,9 +249,8 @@ class CupertinoBackGestureController extends NavigationGestureController {
CupertinoBackGestureController({
@required NavigatorState navigator,
@required this.controller,
}) : super(navigator) {
assert(controller != null);
}
}) : assert(controller != null),
super(navigator);
/// The animation controller that the route uses to drive its transition
/// animation.
......
......@@ -192,11 +192,11 @@ class _RenderCupertinoSlider extends RenderConstrainedBox implements SemanticsAc
Color activeColor,
this.onChanged,
TickerProvider vsync,
}) : _value = value,
}) : assert(value != null && value >= 0.0 && value <= 1.0),
_value = value,
_divisions = divisions,
_activeColor = activeColor,
super(additionalConstraints: const BoxConstraints.tightFor(width: _kSliderWidth, height: _kSliderHeight)) {
assert(value != null && value >= 0.0 && value <= 1.0);
_drag = new HorizontalDragGestureRecognizer()
..onStart = _handleDragStart
..onUpdate = _handleDragUpdate
......
......@@ -141,14 +141,14 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox implements SemanticsAc
@required Color activeColor,
ValueChanged<bool> onChanged,
@required TickerProvider vsync,
}) : _value = value,
_activeColor = activeColor,
_onChanged = onChanged,
_vsync = vsync,
super(additionalConstraints: const BoxConstraints.tightFor(width: _kSwitchWidth, height: _kSwitchHeight)) {
assert(value != null);
assert(activeColor != null);
assert(vsync != null);
}) : assert(value != null),
assert(activeColor != null),
assert(vsync != null),
_value = value,
_activeColor = activeColor,
_onChanged = onChanged,
_vsync = vsync,
super(additionalConstraints: const BoxConstraints.tightFor(width: _kSwitchWidth, height: _kSwitchHeight)) {
_tap = new TapGestureRecognizer()
..onTapDown = _handleTapDown
..onTap = _handleTap
......
......@@ -20,9 +20,8 @@ class DragDownDetails {
/// Creates details for a [GestureDragDownCallback].
///
/// The [globalPosition] argument must not be null.
DragDownDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
DragDownDetails({ this.globalPosition: Offset.zero })
: assert(globalPosition != null);
/// The global position at which the pointer contacted the screen.
///
......@@ -53,9 +52,8 @@ class DragStartDetails {
/// Creates details for a [GestureDragStartCallback].
///
/// The [globalPosition] argument must not be null.
DragStartDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
DragStartDetails({ this.globalPosition: Offset.zero })
: assert(globalPosition != null);
/// The global position at which the pointer contacted the screen.
///
......@@ -99,12 +97,10 @@ class DragUpdateDetails {
this.delta: Offset.zero,
this.primaryDelta,
@required this.globalPosition
}) {
assert(delta != null);
assert(primaryDelta == null
|| (primaryDelta == delta.dx && delta.dy == 0.0)
|| (primaryDelta == delta.dy && delta.dx == 0.0));
}
}) : assert(delta != null),
assert(primaryDelta == null
|| (primaryDelta == delta.dx && delta.dy == 0.0)
|| (primaryDelta == delta.dy && delta.dx == 0.0));
/// The amount the pointer has moved since the previous update.
///
......@@ -158,12 +154,10 @@ class DragEndDetails {
DragEndDetails({
this.velocity: Velocity.zero,
this.primaryVelocity,
}) {
assert(velocity != null);
assert(primaryVelocity == null
|| primaryVelocity == velocity.pixelsPerSecond.dx
|| primaryVelocity == velocity.pixelsPerSecond.dy);
}
}) : assert(velocity != null),
assert(primaryVelocity == null
|| primaryVelocity == velocity.pixelsPerSecond.dx
|| primaryVelocity == velocity.pixelsPerSecond.dy);
/// The velocity the pointer was moving when it stopped contacting the screen.
///
......
......@@ -75,10 +75,9 @@ class LeastSquaresSolver {
/// Creates a least-squares solver.
///
/// The [x], [y], and [w] arguments must not be null.
LeastSquaresSolver(this.x, this.y, this.w) {
assert(x.length == y.length);
assert(y.length == w.length);
}
LeastSquaresSolver(this.x, this.y, this.w)
: assert(x.length == y.length),
assert(y.length == w.length);
/// The x-coordinates of each data point.
final List<double> x;
......
......@@ -27,9 +27,8 @@ abstract class MultiDragPointerState {
/// Creates per-pointer state for a [MultiDragGestureRecognizer].
///
/// The [initialPosition] argument must not be null.
MultiDragPointerState(this.initialPosition) {
assert(initialPosition != null);
}
MultiDragPointerState(this.initialPosition)
: assert(initialPosition != null);
/// The global coordinates of the pointer when the pointer contacted the screen.
final Offset initialPosition;
......@@ -396,8 +395,9 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver
}
class _DelayedPointerState extends MultiDragPointerState {
_DelayedPointerState(Offset initialPosition, Duration delay) : super(initialPosition) {
assert(delay != null);
_DelayedPointerState(Offset initialPosition, Duration delay)
: assert(delay != null),
super(initialPosition) {
_timer = new Timer(delay, _delayPassed);
}
......@@ -481,9 +481,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela
/// can be changed for specific behaviors.
DelayedMultiDragGestureRecognizer({
this.delay: kLongPressTimeout
}) {
assert(delay != null);
}
}) : assert(delay != null);
/// The amount of time the pointer must remain in the same place for the drag
/// to be recognized.
......
......@@ -32,9 +32,8 @@ class ScaleStartDetails {
/// Creates details for [GestureScaleStartCallback].
///
/// The [focalPoint] argument must not be null.
ScaleStartDetails({ this.focalPoint: Offset.zero }) {
assert(focalPoint != null);
}
ScaleStartDetails({ this.focalPoint: Offset.zero })
: assert(focalPoint != null);
/// The initial focal point of the pointers in contact with the screen.
/// Reported in global coordinates.
......@@ -50,10 +49,11 @@ class ScaleUpdateDetails {
///
/// The [focalPoint] and [scale] arguments must not be null. The [scale]
/// argument must be greater than or equal to zero.
ScaleUpdateDetails({ this.focalPoint: Offset.zero, this.scale: 1.0 }) {
assert(focalPoint != null);
assert(scale != null && scale >= 0.0);
}
ScaleUpdateDetails({
this.focalPoint: Offset.zero,
this.scale: 1.0,
}) : assert(focalPoint != null),
assert(scale != null && scale >= 0.0);
/// The focal point of the pointers in contact with the screen. Reported in
/// global coordinates.
......@@ -72,9 +72,8 @@ class ScaleEndDetails {
/// Creates details for [GestureScaleEndCallback].
///
/// The [velocity] argument must not be null.
ScaleEndDetails({ this.velocity: Velocity.zero }) {
assert(velocity != null);
}
ScaleEndDetails({ this.velocity: Velocity.zero })
: assert(velocity != null);
/// The velocity of the last pointer to be lifted off of the screen.
final Velocity velocity;
......
......@@ -12,9 +12,8 @@ class TapDownDetails {
/// Creates details for a [GestureTapDownCallback].
///
/// The [globalPosition] argument must not be null.
TapDownDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
TapDownDetails({ this.globalPosition: Offset.zero })
: assert(globalPosition != null);
/// The global position at which the pointer contacted the screen.
final Offset globalPosition;
......@@ -32,9 +31,8 @@ class TapUpDetails {
/// Creates details for a [GestureTapUpCallback].
///
/// The [globalPosition] argument must not be null.
TapUpDetails({ this.globalPosition: Offset.zero }) {
assert(globalPosition != null);
}
TapUpDetails({ this.globalPosition: Offset.zero })
: assert(globalPosition != null);
/// The global position at which the pointer contacted the screen.
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