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