Commit 69e23538 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

apply prefer_asserts_in_initializer_list lint (#10482)

parent abb76697
...@@ -103,9 +103,8 @@ class WriteBuffer { ...@@ -103,9 +103,8 @@ class WriteBuffer {
/// The byte order used is [Endianness.HOST_ENDIAN] throughout. /// The byte order used is [Endianness.HOST_ENDIAN] throughout.
class ReadBuffer { class ReadBuffer {
/// Creates a [ReadBuffer] for reading from the specified [data]. /// Creates a [ReadBuffer] for reading from the specified [data].
ReadBuffer(this.data) { ReadBuffer(this.data)
assert(data != null); : assert(data != null);
}
/// The underlying data being read. /// The underlying data being read.
final ByteData data; final ByteData data;
......
...@@ -275,9 +275,12 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin { ...@@ -275,9 +275,12 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
const Duration _kHighlightFadeDuration = const Duration(milliseconds: 200); const Duration _kHighlightFadeDuration = const Duration(milliseconds: 200);
class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController { class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController {
_RenderInkFeatures({ RenderBox child, @required this.vsync, this.color }) : super(child) { _RenderInkFeatures({
assert(vsync != null); RenderBox child,
} @required this.vsync,
this.color,
}) : assert(vsync != null),
super(child);
// This class should exist in a 1:1 relationship with a MaterialState object, // This class should exist in a 1:1 relationship with a MaterialState object,
// since there's no current support for dynamically changing the ticker // since there's no current support for dynamically changing the ticker
......
...@@ -1659,9 +1659,9 @@ class BoxDecoration extends Decoration { ...@@ -1659,9 +1659,9 @@ class BoxDecoration extends Decoration {
/// An object that paints a [BoxDecoration] into a canvas. /// An object that paints a [BoxDecoration] into a canvas.
class _BoxDecorationPainter extends BoxPainter { class _BoxDecorationPainter extends BoxPainter {
_BoxDecorationPainter(@required this._decoration, VoidCallback onChange) : super(onChange) { _BoxDecorationPainter(@required this._decoration, VoidCallback onChange)
assert(_decoration != null); : assert(_decoration != null),
} super(onChange);
final BoxDecoration _decoration; final BoxDecoration _decoration;
......
...@@ -219,9 +219,10 @@ class FlutterLogoDecoration extends Decoration { ...@@ -219,9 +219,10 @@ class FlutterLogoDecoration extends Decoration {
/// An object that paints a [BoxDecoration] into a canvas. /// An object that paints a [BoxDecoration] into a canvas.
class _FlutterLogoPainter extends BoxPainter { class _FlutterLogoPainter extends BoxPainter {
_FlutterLogoPainter(this._config) : super(null) { _FlutterLogoPainter(this._config)
assert(_config != null); : assert(_config != null),
assert(_config.debugAssertIsValid()); assert(_config.debugAssertIsValid()),
super(null) {
_prepareText(); _prepareText();
} }
......
...@@ -41,10 +41,13 @@ class TextPainter { ...@@ -41,10 +41,13 @@ class TextPainter {
double textScaleFactor: 1.0, double textScaleFactor: 1.0,
int maxLines, int maxLines,
String ellipsis, String ellipsis,
}) : _text = text, _textAlign = textAlign, _textScaleFactor = textScaleFactor, _maxLines = maxLines, _ellipsis = ellipsis { }) : assert(text == null || text.debugAssertIsValid()),
assert(text == null || text.debugAssertIsValid()); assert(textScaleFactor != null),
assert(textScaleFactor != null); _text = text,
} _textAlign = textAlign,
_textScaleFactor = textScaleFactor,
_maxLines = maxLines,
_ellipsis = ellipsis;
ui.Paragraph _paragraph; ui.Paragraph _paragraph;
bool _needsLayout = true; bool _needsLayout = true;
......
...@@ -26,11 +26,9 @@ class ClampedSimulation extends Simulation { ...@@ -26,11 +26,9 @@ class ClampedSimulation extends Simulation {
this.xMax: double.INFINITY, this.xMax: double.INFINITY,
this.dxMin: double.NEGATIVE_INFINITY, this.dxMin: double.NEGATIVE_INFINITY,
this.dxMax: double.INFINITY this.dxMax: double.INFINITY
}) { }) : assert(simulation != null),
assert(simulation != null); assert(xMax >= xMin),
assert(xMax >= xMin);
assert(dxMax >= dxMin); assert(dxMax >= dxMin);
}
/// The simulation being clamped. Calls to [x], [dx], and [isDone] are /// The simulation being clamped. Calls to [x], [dx], and [isDone] are
/// forwarded to the simulation. /// forwarded to the simulation.
......
...@@ -105,9 +105,8 @@ class BoundedFrictionSimulation extends FrictionSimulation { ...@@ -105,9 +105,8 @@ class BoundedFrictionSimulation extends FrictionSimulation {
double velocity, double velocity,
this._minX, this._minX,
this._maxX this._maxX
) : super(drag, position, velocity) { ) : assert(position.clamp(_minX, _maxX) == position),
assert(position.clamp(_minX, _maxX) == position); super(drag, position, velocity);
}
final double _minX; final double _minX;
final double _maxX; final double _maxX;
......
...@@ -28,16 +28,15 @@ class GravitySimulation extends Simulation { ...@@ -28,16 +28,15 @@ class GravitySimulation extends Simulation {
double distance, double distance,
double endDistance, double endDistance,
double velocity double velocity
) : _a = acceleration, ) : assert(acceleration != null),
assert(distance != null),
assert(velocity != null),
assert(endDistance != null),
assert(endDistance >= 0),
_a = acceleration,
_x = distance, _x = distance,
_v = velocity, _v = velocity,
_end = endDistance { _end = endDistance;
assert(acceleration != null);
assert(distance != null);
assert(velocity != null);
assert(endDistance != null);
assert(endDistance >= 0);
}
final double _x; final double _x;
final double _v; final double _v;
......
...@@ -237,8 +237,8 @@ class OneFrameImageStreamCompleter extends ImageStreamCompleter { ...@@ -237,8 +237,8 @@ class OneFrameImageStreamCompleter extends ImageStreamCompleter {
/// argument on [FlutterErrorDetails] set to true, meaning that by default the /// argument on [FlutterErrorDetails] set to true, meaning that by default the
/// message is only dumped to the console in debug mode (see [new /// message is only dumped to the console in debug mode (see [new
/// FlutterErrorDetails]). /// FlutterErrorDetails]).
OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector informationCollector }) { OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector informationCollector })
assert(image != null); : assert(image != null) {
image.then<Null>(setImage, onError: (dynamic error, StackTrace stack) { image.then<Null>(setImage, onError: (dynamic error, StackTrace stack) {
FlutterError.reportError(new FlutterErrorDetails( FlutterError.reportError(new FlutterErrorDetails(
exception: error, exception: error,
......
...@@ -35,9 +35,8 @@ abstract class MessageCodec<T> { ...@@ -35,9 +35,8 @@ abstract class MessageCodec<T> {
class MethodCall { class MethodCall {
/// Creates a [MethodCall] representing the invocation of [method] with the /// Creates a [MethodCall] representing the invocation of [method] with the
/// specified [arguments]. /// specified [arguments].
MethodCall(this.method, [this.arguments]) { MethodCall(this.method, [this.arguments])
assert(method != null); : assert(method != null);
}
/// The name of the method to be called. /// The name of the method to be called.
final String method; final String method;
...@@ -148,9 +147,7 @@ class PlatformException implements Exception { ...@@ -148,9 +147,7 @@ class PlatformException implements Exception {
@required this.code, @required this.code,
this.message, this.message,
this.details, this.details,
}) { }) : assert(code != null);
assert(code != null);
}
/// An error code. /// An error code.
final String code; final String code;
......
...@@ -224,9 +224,9 @@ abstract class TextInputClient { ...@@ -224,9 +224,9 @@ abstract class TextInputClient {
/// ///
/// * [TextInput.attach] /// * [TextInput.attach]
class TextInputConnection { class TextInputConnection {
TextInputConnection._(this._client) : _id = _nextId++ { TextInputConnection._(this._client)
assert(_client != null); : assert(_client != null),
} _id = _nextId++;
static int _nextId = 1; static int _nextId = 1;
final int _id; final int _id;
......
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