Remove unnecessary null checks (flutter/engine#39113)

This commit is contained in:
Michael Goderbauer 2023-01-25 10:15:02 -08:00 committed by GitHub
parent a5500ec179
commit c545a799d2
66 changed files with 109 additions and 563 deletions

View File

@ -12,8 +12,6 @@ analyzer:
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
# Turned off until null-safe rollout is complete.
unnecessary_null_comparison: ignore
exclude: # DIFFERENT FROM FLUTTER/FLUTTER
# Fixture depends on dart:ui and raises false positives.
- flutter_frontend_server/test/fixtures/lib/main.dart

View File

@ -1,2 +1,2 @@
Signature: 974dd21be7c0e97f436f3758b6de4cee
Signature: ccf8317fb6539998c8f4ff0a96d7f698

View File

@ -375,7 +375,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
Clip clipBehavior = Clip.antiAlias,
ClipRectEngineLayer? oldLayer,
}) {
assert(clipBehavior != null);
assert(clipBehavior != Clip.none);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRect'));
final EngineLayer engineLayer = EngineLayer._();
@ -411,7 +410,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
Clip clipBehavior = Clip.antiAlias,
ClipRRectEngineLayer? oldLayer,
}) {
assert(clipBehavior != null);
assert(clipBehavior != Clip.none);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipRRect'));
final EngineLayer engineLayer = EngineLayer._();
@ -439,7 +437,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
Clip clipBehavior = Clip.antiAlias,
ClipPathEngineLayer? oldLayer,
}) {
assert(clipBehavior != null);
assert(clipBehavior != Clip.none);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushClipPath'));
final EngineLayer engineLayer = EngineLayer._();
@ -494,10 +491,8 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
ColorFilter filter, {
ColorFilterEngineLayer? oldLayer,
}) {
assert(filter != null);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushColorFilter'));
final _ColorFilter nativeFilter = filter._toNativeColorFilter()!;
assert(nativeFilter != null);
final EngineLayer engineLayer = EngineLayer._();
_pushColorFilter(engineLayer, nativeFilter, oldLayer?._nativeLayer);
final ColorFilterEngineLayer layer = ColorFilterEngineLayer._(engineLayer);
@ -523,10 +518,8 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
Offset offset = Offset.zero,
ImageFilterEngineLayer? oldLayer,
}) {
assert(filter != null);
assert(_debugCheckCanBeUsedAsOldLayer(oldLayer, 'pushImageFilter'));
final _ImageFilter nativeFilter = filter._toNativeImageFilter();
assert(nativeFilter != null);
final EngineLayer engineLayer = EngineLayer._();
_pushImageFilter(engineLayer, nativeFilter, offset.dx, offset.dy, oldLayer?._nativeLayer);
final ImageFilterEngineLayer layer = ImageFilterEngineLayer._(engineLayer);
@ -799,7 +792,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
bool freeze = false,
FilterQuality filterQuality = FilterQuality.low,
}) {
assert(offset != null, 'Offset argument was null');
_addTexture(offset.dx, offset.dy, width, height, textureId, freeze, filterQuality.index);
}
@ -828,7 +820,6 @@ class SceneBuilder extends NativeFieldWrapperClass1 {
double width = 0.0,
double height = 0.0,
}) {
assert(offset != null, 'Offset argument was null');
_addPlatformView(offset.dx, offset.dy, width, height, viewId);
}

View File

@ -80,9 +80,7 @@ class SceneNode extends NativeFieldWrapperClass1 {
<String, WeakReference<SceneNodeValue>>{};
static Future<void> _reinitializeScene(String assetKey) async {
final WeakReference<SceneNodeValue>? sceneRef = _ipsceneRegistry == null
? null
: _ipsceneRegistry[assetKey];
final WeakReference<SceneNodeValue>? sceneRef = _ipsceneRegistry[assetKey];
// If a scene for the asset isn't already registered, then there's no
// need to reinitialize it.

View File

@ -12,9 +12,7 @@ abstract class OffsetBase {
///
/// The first argument sets the horizontal component, and the second the
/// vertical component.
const OffsetBase(this._dx, this._dy)
: assert(_dx != null),
assert(_dy != null);
const OffsetBase(this._dx, this._dy);
final double _dx;
final double _dy;
@ -314,7 +312,6 @@ class Offset extends OffsetBase {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static Offset? lerp(Offset? a, Offset? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -590,7 +587,6 @@ class Size extends OffsetBase {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static Size? lerp(Size? a, Size? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -637,11 +633,7 @@ class Rect {
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/rect_from_ltrb.png#gh-light-mode-only)
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/rect_from_ltrb_dark.png#gh-dark-mode-only)
@pragma('vm:entry-point')
const Rect.fromLTRB(this.left, this.top, this.right, this.bottom)
: assert(left != null),
assert(top != null),
assert(right != null),
assert(bottom != null);
const Rect.fromLTRB(this.left, this.top, this.right, this.bottom);
/// Construct a rectangle from its left and top edges, its width, and its
/// height.
@ -891,7 +883,6 @@ class Rect {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static Rect? lerp(Rect? a, Rect? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -1059,7 +1050,6 @@ class Radius {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static Radius? lerp(Radius? a, Radius? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -1268,19 +1258,7 @@ class RRect {
this.brRadiusY = 0.0,
this.blRadiusX = 0.0,
this.blRadiusY = 0.0,
}) : assert(left != null),
assert(top != null),
assert(right != null),
assert(bottom != null),
assert(tlRadiusX != null),
assert(tlRadiusY != null),
assert(trRadiusX != null),
assert(trRadiusY != null),
assert(brRadiusX != null),
assert(brRadiusY != null),
assert(blRadiusX != null),
assert(blRadiusY != null),
assert(tlRadiusX >= 0),
}) : assert(tlRadiusX >= 0),
assert(tlRadiusY >= 0),
assert(trRadiusX >= 0),
assert(trRadiusY >= 0),
@ -1661,7 +1639,6 @@ class RRect {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static RRect? lerp(RRect? a, RRect? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;

View File

@ -138,9 +138,6 @@ void _invoke(void Function()? callback, Zone zone) {
if (callback == null) {
return;
}
assert(zone != null);
if (identical(zone, Zone.current)) {
callback();
} else {
@ -157,9 +154,6 @@ void _invoke1<A>(void Function(A a)? callback, Zone zone, A arg) {
if (callback == null) {
return;
}
assert(zone != null);
if (identical(zone, Zone.current)) {
callback(arg);
} else {
@ -176,9 +170,6 @@ void _invoke2<A1, A2>(void Function(A1 a1, A2 a2)? callback, Zone zone, A1 arg1,
if (callback == null) {
return;
}
assert(zone != null);
if (identical(zone, Zone.current)) {
callback(arg1, arg2);
} else {
@ -197,9 +188,6 @@ void _invoke3<A1, A2, A3>(void Function(A1 a1, A2 a2, A3 a3)? callback, Zone zon
if (callback == null) {
return;
}
assert(zone != null);
if (identical(zone, Zone.current)) {
callback(arg1, arg2, arg3);
} else {

View File

@ -31,7 +31,6 @@ class IsolateNameServer {
///
/// The `name` argument must not be null.
static SendPort? lookupPortByName(String name) {
assert(name != null, "'name' cannot be null.");
return _lookupPortByName(name);
}
@ -49,8 +48,6 @@ class IsolateNameServer {
///
/// The `port` and `name` arguments must not be null.
static bool registerPortWithName(SendPort port, String name) {
assert(port != null, "'port' cannot be null.");
assert(name != null, "'name' cannot be null.");
return _registerPortWithName(port, name);
}
@ -66,7 +63,6 @@ class IsolateNameServer {
///
/// The `name` argument must not be null.
static bool removePortNameMapping(String name) {
assert(name != null, "'name' cannot be null.");
return _removePortNameMapping(name);
}

View File

@ -23,32 +23,27 @@ part of dart.ui;
// which can not be rendered by Skia.
bool _rectIsValid(Rect rect) {
assert(rect != null, 'Rect argument was null.');
assert(!rect.hasNaN, 'Rect argument contained a NaN value.');
return true;
}
bool _rrectIsValid(RRect rrect) {
assert(rrect != null, 'RRect argument was null.');
assert(!rrect.hasNaN, 'RRect argument contained a NaN value.');
return true;
}
bool _offsetIsValid(Offset offset) {
assert(offset != null, 'Offset argument was null.');
assert(!offset.dx.isNaN && !offset.dy.isNaN, 'Offset argument contained a NaN value.');
return true;
}
bool _matrix4IsValid(Float64List matrix4) {
assert(matrix4 != null, 'Matrix4 argument was null.');
assert(matrix4.length == 16, 'Matrix4 must have 16 entries.');
assert(matrix4.every((double value) => value.isFinite), 'Matrix4 entries must be finite.');
return true;
}
bool _radiusIsValid(Radius radius) {
assert(radius != null, 'Radius argument was null.');
assert(!radius.x.isNaN && !radius.y.isNaN, 'Radius argument contained a NaN value.');
return true;
}
@ -259,7 +254,6 @@ class Color {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static Color? lerp(Color? a, Color? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -319,7 +313,6 @@ class Color {
///
/// The [opacity] value may not be null.
static int getAlphaFromOpacity(double opacity) {
assert(opacity != null);
return (clampDouble(opacity, 0.0, 1.0) * 255).round();
}
@ -1196,7 +1189,6 @@ class Paint {
return Color(encoded ^ _kColorDefault);
}
set color(Color value) {
assert(value != null);
final int encoded = value.value ^ _kColorDefault;
_data.setInt32(_kColorOffset, encoded, _kFakeHostEndian);
}
@ -1227,7 +1219,6 @@ class Paint {
return BlendMode.values[encoded ^ _kBlendModeDefault];
}
set blendMode(BlendMode value) {
assert(value != null);
final int encoded = value.index ^ _kBlendModeDefault;
_data.setInt32(_kBlendModeOffset, encoded, _kFakeHostEndian);
}
@ -1239,7 +1230,6 @@ class Paint {
return PaintingStyle.values[_data.getInt32(_kStyleOffset, _kFakeHostEndian)];
}
set style(PaintingStyle value) {
assert(value != null);
final int encoded = value.index;
_data.setInt32(_kStyleOffset, encoded, _kFakeHostEndian);
}
@ -1253,7 +1243,6 @@ class Paint {
return _data.getFloat32(_kStrokeWidthOffset, _kFakeHostEndian);
}
set strokeWidth(double value) {
assert(value != null);
final double encoded = value;
_data.setFloat32(_kStrokeWidthOffset, encoded, _kFakeHostEndian);
}
@ -1266,7 +1255,6 @@ class Paint {
return StrokeCap.values[_data.getInt32(_kStrokeCapOffset, _kFakeHostEndian)];
}
set strokeCap(StrokeCap value) {
assert(value != null);
final int encoded = value.index;
_data.setInt32(_kStrokeCapOffset, encoded, _kFakeHostEndian);
}
@ -1300,7 +1288,6 @@ class Paint {
return StrokeJoin.values[_data.getInt32(_kStrokeJoinOffset, _kFakeHostEndian)];
}
set strokeJoin(StrokeJoin value) {
assert(value != null);
final int encoded = value.index;
_data.setInt32(_kStrokeJoinOffset, encoded, _kFakeHostEndian);
}
@ -1338,7 +1325,6 @@ class Paint {
return _data.getFloat32(_kStrokeMiterLimitOffset, _kFakeHostEndian);
}
set strokeMiterLimit(double value) {
assert(value != null);
final double encoded = value - _kStrokeMiterLimitDefault;
_data.setFloat32(_kStrokeMiterLimitOffset, encoded, _kFakeHostEndian);
}
@ -1383,7 +1369,6 @@ class Paint {
return FilterQuality.values[_data.getInt32(_kFilterQualityOffset, _kFakeHostEndian)];
}
set filterQuality(FilterQuality value) {
assert(value != null);
final int encoded = value.index;
_data.setInt32(_kFilterQualityOffset, encoded, _kFakeHostEndian);
}
@ -2753,7 +2738,6 @@ class Path extends NativeFieldWrapperClass1 {
///
/// The `points` argument is interpreted as offsets from the origin.
void addPolygon(List<Offset> points, bool close) {
assert(points != null);
_addPolygon(_encodePointList(points), close);
}
@ -2777,7 +2761,6 @@ class Path extends NativeFieldWrapperClass1 {
/// after the matrix is translated by the given offset. The matrix is a 4x4
/// matrix stored in column major order.
void addPath(Path path, Offset offset, {Float64List? matrix4}) {
assert(path != null); // path is checked on the engine side
assert(_offsetIsValid(offset));
if (matrix4 != null) {
assert(_matrix4IsValid(matrix4));
@ -2801,7 +2784,6 @@ class Path extends NativeFieldWrapperClass1 {
/// after the matrix is translated by the given `offset`. The matrix is a 4x4
/// matrix stored in column major order.
void extendWithPath(Path path, Offset offset, {Float64List? matrix4}) {
assert(path != null); // path is checked on the engine side
assert(_offsetIsValid(offset));
if (matrix4 != null) {
assert(_matrix4IsValid(matrix4));
@ -2897,8 +2879,6 @@ class Path extends NativeFieldWrapperClass1 {
/// curve order is reduced where possible so that cubics may be turned into
/// quadratics, and quadratics maybe turned into lines.
static Path combine(PathOperation operation, Path path1, Path path2) {
assert(path1 != null);
assert(path2 != null);
final Path path = Path();
if (path._op(path1, path2, operation.index)) {
return path;
@ -2953,9 +2933,7 @@ class Tangent {
/// Creates a [Tangent] with the given values.
///
/// The arguments must not be null.
const Tangent(this.position, this.vector)
: assert(position != null),
assert(vector != null);
const Tangent(this.position, this.vector);
/// Creates a [Tangent] based on the angle rather than the vector.
///
@ -3021,7 +2999,7 @@ class PathMetrics extends collection.IterableBase<PathMetric> {
/// Used by [PathMetrics] to track iteration from one segment of a path to the
/// next for measurement.
class PathMetricIterator implements Iterator<PathMetric> {
PathMetricIterator._(this._pathMeasure) : assert(_pathMeasure != null);
PathMetricIterator._(this._pathMeasure);
PathMetric? _pathMetric;
final _PathMeasure _pathMeasure;
@ -3065,8 +3043,7 @@ class PathMetricIterator implements Iterator<PathMetric> {
/// the path.
class PathMetric {
PathMetric._(this._measure)
: assert(_measure != null),
length = _measure.length(_measure.currentContourIndex),
: length = _measure.length(_measure.currentContourIndex),
isClosed = _measure.isClosed(_measure.currentContourIndex),
contourIndex = _measure.currentContourIndex;
@ -3252,8 +3229,7 @@ class MaskFilter {
const MaskFilter.blur(
this._style,
this._sigma,
) : assert(_style != null),
assert(_sigma != null);
);
final BlurStyle _style;
final double _sigma;
@ -3472,28 +3448,24 @@ class ColorFilter implements ImageFilter {
/// avoid repainting.
class _ColorFilter extends NativeFieldWrapperClass1 {
_ColorFilter.mode(this.creator)
: assert(creator != null),
assert(creator._type == ColorFilter._kTypeMode) {
: assert(creator._type == ColorFilter._kTypeMode) {
_constructor();
_initMode(creator._color!.value, creator._blendMode!.index);
}
_ColorFilter.matrix(this.creator)
: assert(creator != null),
assert(creator._type == ColorFilter._kTypeMatrix) {
: assert(creator._type == ColorFilter._kTypeMatrix) {
_constructor();
_initMatrix(Float32List.fromList(creator._matrix!));
}
_ColorFilter.linearToSrgbGamma(this.creator)
: assert(creator != null),
assert(creator._type == ColorFilter._kTypeLinearToSrgbGamma) {
: assert(creator._type == ColorFilter._kTypeLinearToSrgbGamma) {
_constructor();
_initLinearToSrgbGamma();
}
_ColorFilter.srgbToLinearGamma(this.creator)
: assert(creator != null),
assert(creator._type == ColorFilter._kTypeSrgbToLinearGamma) {
: assert(creator._type == ColorFilter._kTypeSrgbToLinearGamma) {
_constructor();
_initSrgbToLinearGamma();
}
@ -3531,25 +3503,18 @@ class _ColorFilter extends NativeFieldWrapperClass1 {
abstract class ImageFilter {
/// Creates an image filter that applies a Gaussian blur.
factory ImageFilter.blur({ double sigmaX = 0.0, double sigmaY = 0.0, TileMode tileMode = TileMode.clamp }) {
assert(sigmaX != null);
assert(sigmaY != null);
assert(tileMode != null);
return _GaussianBlurImageFilter(sigmaX: sigmaX, sigmaY: sigmaY, tileMode: tileMode);
}
/// Creates an image filter that dilates each input pixel's channel values
/// to the max value within the given radii along the x and y axes.
factory ImageFilter.dilate({ double radiusX = 0.0, double radiusY = 0.0 }) {
assert(radiusX != null);
assert(radiusY != null);
return _DilateImageFilter(radiusX: radiusX, radiusY: radiusY);
}
/// Create a filter that erodes each input pixel's channel values
/// to the minimum channel value within the given radii along the x and y axes.
factory ImageFilter.erode({ double radiusX = 0.0, double radiusY = 0.0 }) {
assert(radiusX != null);
assert(radiusY != null);
return _ErodeImageFilter(radiusX: radiusX, radiusY: radiusY);
}
@ -3559,8 +3524,6 @@ abstract class ImageFilter {
/// when used with [BackdropFilter] would magnify the background image.
factory ImageFilter.matrix(Float64List matrix4,
{ FilterQuality filterQuality = FilterQuality.low }) {
assert(matrix4 != null);
assert(filterQuality != null);
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
}
@ -3573,7 +3536,6 @@ abstract class ImageFilter {
/// subsequently applying `inner` and `outer`, i.e.,
/// result = outer(inner(source)).
factory ImageFilter.compose({ required ImageFilter outer, required ImageFilter inner }) {
assert(inner != null && outer != null);
return _ComposeImageFilter(innerFilter: inner, outerFilter: outer);
}
@ -3758,8 +3720,7 @@ class _ComposeImageFilter implements ImageFilter {
class _ImageFilter extends NativeFieldWrapperClass1 {
/// Creates an image filter that applies a Gaussian blur.
_ImageFilter.blur(_GaussianBlurImageFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
_constructor();
_initBlur(filter.sigmaX, filter.sigmaY, filter.tileMode.index);
}
@ -3767,8 +3728,7 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
/// Creates an image filter that dilates each input pixel's channel values
/// to the max value within the given radii along the x and y axes.
_ImageFilter.dilate(_DilateImageFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
_constructor();
_initDilate(filter.radiusX, filter.radiusY);
}
@ -3776,8 +3736,7 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
/// Create a filter that erodes each input pixel's channel values
/// to the minimum channel value within the given radii along the x and y axes.
_ImageFilter.erode(_ErodeImageFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
_constructor();
_initErode(filter.radiusX, filter.radiusY);
}
@ -3787,8 +3746,7 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
/// For example, applying a positive scale matrix (see [Matrix4.diagonal3])
/// when used with [BackdropFilter] would magnify the background image.
_ImageFilter.matrix(_MatrixImageFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
if (filter.data.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
}
@ -3798,8 +3756,7 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
/// Converts a color filter to an image filter.
_ImageFilter.fromColorFilter(ColorFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
_constructor();
final _ColorFilter? nativeFilter = filter._toNativeColorFilter();
_initColorFilter(nativeFilter);
@ -3807,8 +3764,7 @@ class _ImageFilter extends NativeFieldWrapperClass1 {
/// Composes `_innerFilter` with `_outerFilter`.
_ImageFilter.composed(_ComposeImageFilter filter)
: assert(filter != null),
creator = filter {
: creator = filter {
_constructor();
final _ImageFilter nativeFilterInner = filter.innerFilter._toNativeImageFilter();
final _ImageFilter nativeFilterOuter = filter.outerFilter._toNativeImageFilter();
@ -3981,7 +3937,6 @@ Int32List _encodeColorList(List<Color> colors) {
}
Float32List _encodePointList(List<Offset> points) {
assert(points != null);
final int pointCount = points.length;
final Float32List result = Float32List(pointCount * 2);
for (int i = 0; i < pointCount; ++i) {
@ -4047,8 +4002,6 @@ class Gradient extends Shader {
Float64List? matrix4,
]) : assert(_offsetIsValid(from)),
assert(_offsetIsValid(to)),
assert(colors != null),
assert(tileMode != null),
assert(matrix4 == null || _matrix4IsValid(matrix4)),
super._() {
_validateColorStops(colors, colorStops);
@ -4099,8 +4052,6 @@ class Gradient extends Shader {
Offset? focal,
double focalRadius = 0.0
]) : assert(_offsetIsValid(center)),
assert(colors != null),
assert(tileMode != null),
assert(matrix4 == null || _matrix4IsValid(matrix4)),
super._() {
_validateColorStops(colors, colorStops);
@ -4155,10 +4106,6 @@ class Gradient extends Shader {
double endAngle = math.pi * 2,
Float64List? matrix4,
]) : assert(_offsetIsValid(center)),
assert(colors != null),
assert(tileMode != null),
assert(startAngle != null),
assert(endAngle != null),
assert(startAngle < endAngle),
assert(matrix4 == null || _matrix4IsValid(matrix4)),
super._() {
@ -4248,11 +4195,7 @@ class ImageShader extends Shader {
ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4, {
FilterQuality? filterQuality,
}) :
assert(image != null), // image is checked on the engine side
assert(!image.debugDisposed),
assert(tmx != null),
assert(tmy != null),
assert(matrix4 != null),
super._() {
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
@ -4337,9 +4280,7 @@ class FragmentProgram extends NativeFieldWrapperClass1 {
// If a shader for the asset isn't already registered, then there's no
// need to reinitialize it. The new shader will be loaded and initialized
// the next time the program access it.
final WeakReference<FragmentProgram>? programRef = _shaderRegistry == null
? null
: _shaderRegistry[assetKey];
final WeakReference<FragmentProgram>? programRef = _shaderRegistry[assetKey];
if (programRef == null) {
return;
}
@ -4588,8 +4529,7 @@ class Vertices extends NativeFieldWrapperClass1 {
List<Color>? colors,
List<Offset>? textureCoordinates,
List<int>? indices,
}) : assert(mode != null),
assert(positions != null) {
}) {
if (colors != null && colors.length != positions.length) {
throw ArgumentError('"positions" and "colors" lengths must match.');
}
@ -4673,8 +4613,7 @@ class Vertices extends NativeFieldWrapperClass1 {
Int32List? colors,
Float32List? textureCoordinates,
Uint16List? indices,
}) : assert(mode != null),
assert(positions != null) {
}) {
if (positions.length % 2 != 0) {
throw ArgumentError('"positions" must have an even number of entries (each coordinate is an x,y pair).');
}
@ -4813,7 +4752,7 @@ class Canvas extends NativeFieldWrapperClass1 {
/// To end the recording, call [PictureRecorder.endRecording] on the
/// given recorder.
@pragma('vm:entry-point')
Canvas(PictureRecorder recorder, [ Rect? cullRect ]) : assert(recorder != null) {
Canvas(PictureRecorder recorder, [ Rect? cullRect ]) {
if (recorder.isRecording) {
throw ArgumentError('"recorder" must not already be associated with another Canvas.');
}
@ -4952,7 +4891,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// * [BlendMode], which discusses the use of [Paint.blendMode] with
/// [saveLayer].
void saveLayer(Rect? bounds, Paint paint) {
assert(paint != null);
if (bounds == null) {
_saveLayerWithoutBounds(paint._objects, paint._data);
} else {
@ -5028,7 +4966,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// Multiply the current transform by the specified 44 transformation matrix
/// specified as a list of values in column-major order.
void transform(Float64List matrix4) {
assert(matrix4 != null);
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
}
@ -5070,8 +5007,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// current clip.
void clipRect(Rect rect, { ClipOp clipOp = ClipOp.intersect, bool doAntiAlias = true }) {
assert(_rectIsValid(rect));
assert(clipOp != null);
assert(doAntiAlias != null);
_clipRect(rect.left, rect.top, rect.right, rect.bottom, clipOp.index, doAntiAlias);
}
@ -5090,7 +5025,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// discussion of how to address that and some examples of using [clipRRect].
void clipRRect(RRect rrect, {bool doAntiAlias = true}) {
assert(_rrectIsValid(rrect));
assert(doAntiAlias != null);
_clipRRect(rrect._getValue32(), doAntiAlias);
}
@ -5108,8 +5042,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// in incorrect blending at the clip boundary. See [saveLayer] for a
/// discussion of how to address that.
void clipPath(Path path, {bool doAntiAlias = true}) {
assert(path != null); // path is checked on the engine side
assert(doAntiAlias != null);
_clipPath(path, doAntiAlias);
}
@ -5204,8 +5136,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// [BlendMode], with the given color being the source and the background
/// being the destination.
void drawColor(Color color, BlendMode blendMode) {
assert(color != null);
assert(blendMode != null);
_drawColor(color.value, blendMode.index);
}
@ -5222,7 +5152,6 @@ class Canvas extends NativeFieldWrapperClass1 {
void drawLine(Offset p1, Offset p2, Paint paint) {
assert(_offsetIsValid(p1));
assert(_offsetIsValid(p2));
assert(paint != null);
_drawLine(p1.dx, p1.dy, p2.dx, p2.dy, paint._objects, paint._data);
}
@ -5234,7 +5163,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// To fill the canvas with a solid color and blend mode, consider
/// [drawColor] instead.
void drawPaint(Paint paint) {
assert(paint != null);
_drawPaint(paint._objects, paint._data);
}
@ -5248,7 +5176,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/canvas_rect_dark.png#gh-dark-mode-only)
void drawRect(Rect rect, Paint paint) {
assert(_rectIsValid(rect));
assert(paint != null);
_drawRect(rect.left, rect.top, rect.right, rect.bottom, paint._objects, paint._data);
}
@ -5262,7 +5189,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/canvas_rrect_dark.png#gh-dark-mode-only)
void drawRRect(RRect rrect, Paint paint) {
assert(_rrectIsValid(rrect));
assert(paint != null);
_drawRRect(rrect._getValue32(), paint._objects, paint._data);
}
@ -5277,7 +5203,6 @@ class Canvas extends NativeFieldWrapperClass1 {
void drawDRRect(RRect outer, RRect inner, Paint paint) {
assert(_rrectIsValid(outer));
assert(_rrectIsValid(inner));
assert(paint != null);
_drawDRRect(outer._getValue32(), inner._getValue32(), paint._objects, paint._data);
}
@ -5292,7 +5217,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/canvas_oval_dark.png#gh-dark-mode-only)
void drawOval(Rect rect, Paint paint) {
assert(_rectIsValid(rect));
assert(paint != null);
_drawOval(rect.left, rect.top, rect.right, rect.bottom, paint._objects, paint._data);
}
@ -5308,7 +5232,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// ![](https://flutter.github.io/assets-for-api-docs/assets/dart-ui/canvas_circle_dark.png#gh-dark-mode-only)
void drawCircle(Offset c, double radius, Paint paint) {
assert(_offsetIsValid(c));
assert(paint != null);
_drawCircle(c.dx, c.dy, radius, paint._objects, paint._data);
}
@ -5331,7 +5254,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// This method is optimized for drawing arcs and should be faster than [Path.arcTo].
void drawArc(Rect rect, double startAngle, double sweepAngle, bool useCenter, Paint paint) {
assert(_rectIsValid(rect));
assert(paint != null);
_drawArc(rect.left, rect.top, rect.right, rect.bottom, startAngle, sweepAngle, useCenter, paint._objects, paint._data);
}
@ -5353,8 +5275,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// [Paint.style]. If the path is filled, then sub-paths within it are
/// implicitly closed (see [Path.close]).
void drawPath(Path path, Paint paint) {
assert(path != null); // path is checked on the engine side
assert(paint != null);
_drawPath(path, paint._objects, paint._data);
}
@ -5364,10 +5284,8 @@ class Canvas extends NativeFieldWrapperClass1 {
/// Draws the given [Image] into the canvas with its top-left corner at the
/// given [Offset]. The image is composited into the canvas using the given [Paint].
void drawImage(Image image, Offset offset, Paint paint) {
assert(image != null); // image is checked on the engine side
assert(!image.debugDisposed);
assert(_offsetIsValid(offset));
assert(paint != null);
final String? error = _drawImage(image._image, offset.dx, offset.dy, paint._objects, paint._data, paint.filterQuality.index);
if (error != null) {
throw PictureRasterizationException._(error, stack: image._debugStack);
@ -5387,11 +5305,9 @@ class Canvas extends NativeFieldWrapperClass1 {
/// image) can be batched into a single call to [drawAtlas] to improve
/// performance.
void drawImageRect(Image image, Rect src, Rect dst, Paint paint) {
assert(image != null); // image is checked on the engine side
assert(!image.debugDisposed);
assert(_rectIsValid(src));
assert(_rectIsValid(dst));
assert(paint != null);
final String? error = _drawImageRect(image._image,
src.left,
src.top,
@ -5438,11 +5354,9 @@ class Canvas extends NativeFieldWrapperClass1 {
/// cover the destination rectangle while maintaining their relative
/// positions.
void drawImageNine(Image image, Rect center, Rect dst, Paint paint) {
assert(image != null); // image is checked on the engine side
assert(!image.debugDisposed);
assert(_rectIsValid(center));
assert(_rectIsValid(dst));
assert(paint != null);
final String? error = _drawImageNine(image._image,
center.left,
center.top,
@ -5478,7 +5392,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// Draw the given picture onto the canvas. To create a picture, see
/// [PictureRecorder].
void drawPicture(Picture picture) {
assert(picture != null); // picture is checked on the engine side
assert(!picture.debugDisposed);
_drawPicture(picture);
}
@ -5507,7 +5420,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// described by adding half of the [ParagraphConstraints.width] given to
/// [Paragraph.layout], to the `offset` argument's [Offset.dx] coordinate.
void drawParagraph(Paragraph paragraph, Offset offset) {
assert(paragraph != null);
assert(!paragraph.debugDisposed);
assert(_offsetIsValid(offset));
assert(!paragraph._needsLayout);
@ -5526,9 +5438,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// * [drawRawPoints], which takes `points` as a [Float32List] rather than a
/// [List<Offset>].
void drawPoints(PointMode pointMode, List<Offset> points, Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
_drawPoints(paint._objects, paint._data, pointMode.index, _encodePointList(points));
}
@ -5545,9 +5454,6 @@ class Canvas extends NativeFieldWrapperClass1 {
/// * [drawPoints], which takes `points` as a [List<Offset>] rather than a
/// [List<Float32List>].
void drawRawPoints(PointMode pointMode, Float32List points, Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
if (points.length % 2 != 0) {
throw ArgumentError('"points" must have an even number of values.');
}
@ -5586,10 +5492,7 @@ class Canvas extends NativeFieldWrapperClass1 {
/// rather than unencoded lists.
/// * [paint], Image shaders can be used to draw images on a triangular mesh.
void drawVertices(Vertices vertices, BlendMode blendMode, Paint paint) {
assert(vertices != null); // vertices is checked on the engine side
assert(!vertices.debugDisposed);
assert(paint != null);
assert(blendMode != null);
_drawVertices(vertices, blendMode.index, paint._objects, paint._data);
}
@ -5734,12 +5637,8 @@ class Canvas extends NativeFieldWrapperClass1 {
BlendMode? blendMode,
Rect? cullRect,
Paint paint) {
assert(atlas != null); // atlas is checked on the engine side
assert(!atlas.debugDisposed);
assert(transforms != null);
assert(rects != null);
assert(colors == null || colors.isEmpty || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (transforms.length != rectCount) {
@ -5938,11 +5837,7 @@ class Canvas extends NativeFieldWrapperClass1 {
BlendMode? blendMode,
Rect? cullRect,
Paint paint) {
assert(atlas != null); // atlas is checked on the engine side
assert(rstTransforms != null);
assert(rects != null);
assert(colors == null || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (rstTransforms.length != rectCount) {
@ -5985,9 +5880,6 @@ class Canvas extends NativeFieldWrapperClass1 {
///
/// The arguments must not be null.
void drawShadow(Path path, Color color, double elevation, bool transparentOccluder) {
assert(path != null); // path is checked on the engine side
assert(color != null);
assert(transparentOccluder != null);
_drawShadow(path, color.value, elevation, transparentOccluder);
}
@ -6188,9 +6080,7 @@ class Shadow {
this.color = const Color(_kColorDefault),
this.offset = Offset.zero,
this.blurRadius = 0.0,
}) : assert(color != null, 'Text shadow color was null.'),
assert(offset != null, 'Text shadow offset was null.'),
assert(blurRadius >= 0.0, 'Text shadow blur radius should be non-negative.');
}) : assert(blurRadius >= 0.0, 'Text shadow blur radius should be non-negative.');
static const int _kColorDefault = 0xFF000000;
// Constants for shadow encoding.
@ -6277,7 +6167,6 @@ class Shadow {
/// an [AnimationController].
/// {@endtemplate}
static Shadow? lerp(Shadow? a, Shadow? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -6303,7 +6192,6 @@ class Shadow {
///
/// {@macro dart.ui.shadow.lerp}
static List<Shadow>? lerpList(List<Shadow>? a, List<Shadow>? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
@ -6351,25 +6239,20 @@ class Shadow {
int shadowOffset = 0;
for (int shadowIndex = 0; shadowIndex < shadows.length; ++shadowIndex) {
final Shadow shadow = shadows[shadowIndex];
// TODO(yjbanov): remove the null check when the framework is migrated. While the list
// of shadows contains non-nullable elements, unmigrated code can still
// pass nulls.
if (shadow != null) {
shadowOffset = shadowIndex * _kBytesPerShadow;
shadowOffset = shadowIndex * _kBytesPerShadow;
shadowsData.setInt32(_kColorOffset + shadowOffset,
shadow.color.value ^ Shadow._kColorDefault, _kFakeHostEndian);
shadowsData.setInt32(_kColorOffset + shadowOffset,
shadow.color.value ^ Shadow._kColorDefault, _kFakeHostEndian);
shadowsData.setFloat32(_kXOffset + shadowOffset,
shadow.offset.dx, _kFakeHostEndian);
shadowsData.setFloat32(_kXOffset + shadowOffset,
shadow.offset.dx, _kFakeHostEndian);
shadowsData.setFloat32(_kYOffset + shadowOffset,
shadow.offset.dy, _kFakeHostEndian);
shadowsData.setFloat32(_kYOffset + shadowOffset,
shadow.offset.dy, _kFakeHostEndian);
final double blurSigma = Shadow.convertRadiusToSigma(shadow.blurRadius);
shadowsData.setFloat32(_kBlurOffset + shadowOffset,
blurSigma, _kFakeHostEndian);
}
final double blurSigma = Shadow.convertRadiusToSigma(shadow.blurRadius);
shadowsData.setFloat32(_kBlurOffset + shadowOffset,
blurSigma, _kFakeHostEndian);
}
return shadowsData;

View File

@ -1943,8 +1943,7 @@ class Locale {
const Locale(
this._languageCode, [
this._countryCode,
]) : assert(_languageCode != null),
assert(_languageCode != ''),
]) : assert(_languageCode != ''),
scriptCode = null;
/// Creates a new Locale object.
@ -1971,8 +1970,7 @@ class Locale {
String languageCode = 'und',
this.scriptCode,
String? countryCode,
}) : assert(languageCode != null),
assert(languageCode != ''),
}) : assert(languageCode != ''),
_languageCode = languageCode,
assert(scriptCode != ''),
assert(countryCode != ''),

View File

@ -12,8 +12,7 @@ class CallbackHandle {
///
/// Only values produced by a call to [CallbackHandle.toRawHandle] should be
/// used, otherwise this object will be an invalid handle.
CallbackHandle.fromRawHandle(this._handle)
: assert(_handle != null, "'_handle' must not be null.");
CallbackHandle.fromRawHandle(this._handle);
final int _handle;
@ -60,7 +59,6 @@ class PluginUtilities {
/// original callback. If `callback` is not a top-level or static function,
/// null is returned.
static CallbackHandle? getCallbackHandle(Function callback) {
assert(callback != null, "'callback' must not be null.");
return _forwardCache.putIfAbsent(callback, () {
final int? handle = _getCallbackHandle(callback);
return handle != null ? CallbackHandle.fromRawHandle(handle) : null;
@ -76,7 +74,6 @@ class PluginUtilities {
/// [PluginUtilities.getCallbackHandle], null is returned. Otherwise, a
/// tear-off of the callback associated with `handle` is returned.
static Function? getCallbackFromHandle(CallbackHandle handle) {
assert(handle != null, "'handle' must not be null.");
return _backwardCache.putIfAbsent(
handle, () => _getCallbackFromHandle(handle.toRawHandle()));
}

View File

@ -421,7 +421,7 @@ class PointerData {
/// A sequence of reports about the state of pointers.
class PointerDataPacket {
/// Creates a packet of pointer data reports.
const PointerDataPacket({ this.data = const <PointerData>[] }) : assert(data != null);
const PointerDataPacket({ this.data = const <PointerData>[] });
/// Data about the individual pointers in this packet.
///

View File

@ -13,7 +13,7 @@ part of dart.ui;
/// See also:
/// - file://./../../lib/ui/semantics/semantics_node.h
class SemanticsAction {
const SemanticsAction._(this.index) : assert(index != null);
const SemanticsAction._(this.index);
static const int _kTapIndex = 1 << 0;
static const int _kLongPressIndex = 1 << 1;
@ -289,7 +289,7 @@ class SemanticsAction {
// accessibility services, `flutter_test/controller.dart#SemanticsController._importantFlags`
// must be updated as well.
class SemanticsFlag {
const SemanticsFlag._(this.index) : assert(index != null);
const SemanticsFlag._(this.index);
/// The numerical value for this flag.
///
@ -892,10 +892,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
required Int32List additionalActions,
}) {
assert(_matrix4IsValid(transform));
assert(
scrollChildren == 0 || scrollChildren == null || (scrollChildren > 0 && childrenInHitTestOrder != null),
'If a node has scrollChildren, it must have childrenInHitTestOrder',
);
_updateNode(
id,
flags,
@ -1025,8 +1021,6 @@ class SemanticsUpdateBuilder extends NativeFieldWrapperClass1 {
/// [SemanticsAction.index] value. For custom actions this argument should not be
/// provided.
void updateCustomAction({required int id, String? label, String? hint, int overrideId = -1}) {
assert(id != null);
assert(overrideId != null);
_updateCustomAction(id, label ?? '', hint ?? '', overrideId);
}
@Native<Void Function(Pointer<Void>, Int32, Handle, Handle, Int32)>(symbol: 'SemanticsUpdateBuilder::updateCustomAction')

View File

@ -82,7 +82,6 @@ class FontWeight {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static FontWeight? lerp(FontWeight? a, FontWeight? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
@ -141,9 +140,7 @@ class FontFeature {
const FontFeature(
this.feature,
[ this.value = 1 ]
) : assert(feature != null),
assert(feature.length == 4, 'Feature tag must be exactly four characters long.'),
assert(value != null),
) : assert(feature.length == 4, 'Feature tag must be exactly four characters long.'),
assert(value >= 0, 'Feature value must be zero or a positive integer.');
/// Create a [FontFeature] object that enables the feature with the given tag.
@ -958,9 +955,7 @@ class FontVariation {
const FontVariation(
this.axis,
this.value,
) : assert(axis != null),
assert(axis.length == 4, 'Axis tag must be exactly four characters long.'),
assert(value != null);
) : assert(axis.length == 4, 'Axis tag must be exactly four characters long.');
/// The tag that identifies the design axis. Must consist of 4 ASCII
/// characters.
@ -2258,8 +2253,7 @@ class TextPosition {
const TextPosition({
required this.offset,
this.affinity = TextAffinity.downstream,
}) : assert(offset != null),
assert(affinity != null);
});
/// The index of the character that immediately follows the position in the
/// string representation of the text.
@ -2312,14 +2306,14 @@ class TextRange {
const TextRange({
required this.start,
required this.end,
}) : assert(start != null && start >= -1),
assert(end != null && end >= -1);
}) : assert(start >= -1),
assert(end >= -1);
/// A text range that starts and ends at offset.
///
/// The [offset] argument must be non-null and greater than or equal to -1.
const TextRange.collapsed(int offset)
: assert(offset != null && offset >= -1),
: assert(offset >= -1),
start = offset,
end = offset;
@ -2395,7 +2389,7 @@ class ParagraphConstraints {
/// The [width] argument must not be null.
const ParagraphConstraints({
required this.width,
}) : assert(width != null);
});
/// The width the paragraph should use whey computing the positions of glyphs.
///
@ -2790,8 +2784,6 @@ class Paragraph extends NativeFieldWrapperClass1 {
///
/// See [BoxHeightStyle] and [BoxWidthStyle] for full descriptions of each option.
List<TextBox> getBoxesForRange(int start, int end, {BoxHeightStyle boxHeightStyle = BoxHeightStyle.tight, BoxWidthStyle boxWidthStyle = BoxWidthStyle.tight}) {
assert(boxHeightStyle != null);
assert(boxWidthStyle != null);
return _decodeTextBoxes(_getBoxesForRange(start, end, boxHeightStyle.index, boxWidthStyle.index));
}

View File

@ -7,9 +7,7 @@
part of ui;
abstract class OffsetBase {
const OffsetBase(this._dx, this._dy)
: assert(_dx != null),
assert(_dy != null);
const OffsetBase(this._dx, this._dy);
final double _dx;
final double _dy;
@ -57,7 +55,6 @@ class Offset extends OffsetBase {
Offset operator %(double operand) => Offset(dx % operand, dy % operand);
Rect operator &(Size other) => Rect.fromLTWH(dx, dy, other.width, other.height);
static Offset? lerp(Offset? a, Offset? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -148,7 +145,6 @@ class Size extends OffsetBase {
Size get flipped => Size(height, width);
static Size? lerp(Size? a, Size? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -180,11 +176,7 @@ class Size extends OffsetBase {
}
class Rect {
const Rect.fromLTRB(this.left, this.top, this.right, this.bottom)
: assert(left != null),
assert(top != null),
assert(right != null),
assert(bottom != null);
const Rect.fromLTRB(this.left, this.top, this.right, this.bottom);
const Rect.fromLTWH(double left, double top, double width, double height)
: this.fromLTRB(left, top, left + width, top + height);
@ -291,7 +283,6 @@ class Rect {
}
static Rect? lerp(Rect? a, Rect? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -368,7 +359,6 @@ class Radius {
Radius operator ~/(double operand) => Radius.elliptical((x ~/ operand).toDouble(), (y ~/ operand).toDouble());
Radius operator %(double operand) => Radius.elliptical(x % operand, y % operand);
static Radius? lerp(Radius? a, Radius? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -566,19 +556,7 @@ class RRect {
this.blRadiusX = 0.0,
this.blRadiusY = 0.0,
bool uniformRadii = false,
}) : assert(left != null),
assert(top != null),
assert(right != null),
assert(bottom != null),
assert(tlRadiusX != null),
assert(tlRadiusY != null),
assert(trRadiusX != null),
assert(trRadiusY != null),
assert(brRadiusX != null),
assert(brRadiusY != null),
assert(blRadiusX != null),
assert(blRadiusY != null),
assert(tlRadiusX >= 0),
}) : assert(tlRadiusX >= 0),
assert(tlRadiusY >= 0),
assert(trRadiusX >= 0),
assert(trRadiusY >= 0),
@ -832,7 +810,6 @@ class RRect {
}
static RRect? lerp(RRect? a, RRect? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;

View File

@ -7,14 +7,12 @@ part of ui;
// ignore: unused_element, Used in Shader assert.
bool _offsetIsValid(Offset offset) {
assert(offset != null, 'Offset argument was null.');
assert(!offset.dx.isNaN && !offset.dy.isNaN, 'Offset argument contained a NaN value.');
return true;
}
// ignore: unused_element, Used in Shader assert.
bool _matrix4IsValid(Float32List matrix4) {
assert(matrix4 != null, 'Matrix4 argument was null.');
assert(matrix4.length == 16, 'Matrix4 must have 16 entries.');
return true;
}
@ -93,7 +91,6 @@ class Color {
}
static Color? lerp(Color? a, Color? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -145,7 +142,6 @@ class Color {
}
static int getAlphaFromOpacity(double opacity) {
assert(opacity != null);
return (clampDouble(opacity, 0.0, 1.0) * 255).round();
}
@ -379,8 +375,7 @@ class MaskFilter {
const MaskFilter.blur(
this._style,
this._sigma,
) : assert(_style != null),
assert(_sigma != null);
);
final BlurStyle _style;
final double _sigma;
@ -651,9 +646,7 @@ class Shadow {
this.color = const Color(_kColorDefault),
this.offset = Offset.zero,
this.blurRadius = 0.0,
}) : assert(color != null, 'Text shadow color was null.'),
assert(offset != null, 'Text shadow offset was null.'),
assert(blurRadius >= 0.0, 'Text shadow blur radius should be non-negative.');
}) : assert(blurRadius >= 0.0, 'Text shadow blur radius should be non-negative.');
static const int _kColorDefault = 0xFF000000;
final Color color;
@ -681,7 +674,6 @@ class Shadow {
}
static Shadow? lerp(Shadow? a, Shadow? b, double t) {
assert(t != null);
if (b == null) {
if (a == null) {
return null;
@ -702,7 +694,6 @@ class Shadow {
}
static List<Shadow>? lerpList(List<Shadow>? a, List<Shadow>? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}

View File

@ -26,9 +26,7 @@ abstract class PathMetric {
}
class Tangent {
const Tangent(this.position, this.vector)
: assert(position != null),
assert(vector != null);
const Tangent(this.position, this.vector);
factory Tangent.fromAngle(Offset position, double angle) {
return Tangent(position, Offset(math.cos(angle), math.sin(angle)));
}

View File

@ -443,16 +443,14 @@ class Locale {
const Locale(
this._languageCode, [
this._countryCode,
]) : assert(_languageCode != null),
assert(_languageCode != ''),
]) : assert(_languageCode != ''),
scriptCode = null;
const Locale.fromSubtags({
String languageCode = 'und',
this.scriptCode,
String? countryCode,
}) : assert(languageCode != null),
assert(languageCode != ''),
}) : assert(languageCode != ''),
_languageCode = languageCode,
assert(scriptCode != ''),
assert(countryCode != ''),

View File

@ -151,7 +151,6 @@ class PointerData {
}
class PointerDataPacket {
const PointerDataPacket({this.data = const <PointerData>[]})
: assert(data != null);
const PointerDataPacket({this.data = const <PointerData>[]});
final List<PointerData> data;
}

View File

@ -5,7 +5,7 @@
part of ui;
class SemanticsAction {
const SemanticsAction._(this.index) : assert(index != null);
const SemanticsAction._(this.index);
static const int _kTapIndex = 1 << 0;
static const int _kLongPressIndex = 1 << 1;
@ -134,7 +134,7 @@ class SemanticsAction {
}
class SemanticsFlag {
const SemanticsFlag._(this.index) : assert(index != null);
const SemanticsFlag._(this.index);
final int index;

View File

@ -1011,13 +1011,10 @@ class ContextStateHandle {
context.translate(shaderBounds!.left, shaderBounds.top);
}
}
} else if (paint.color != null) {
} else {
final String? colorString = colorValueToCssString(paint.color);
fillStyle = colorString;
strokeStyle = colorString;
} else {
fillStyle = '#000000';
strokeStyle = '#000000';
}
final ui.MaskFilter? maskFilter = paint.maskFilter;

View File

@ -22,7 +22,6 @@ import 'vertices.dart';
/// An implementation of [ui.Canvas] that is backed by a CanvasKit canvas.
class CanvasKitCanvas implements ui.Canvas {
factory CanvasKitCanvas(ui.PictureRecorder recorder, [ui.Rect? cullRect]) {
assert(recorder != null);
if (recorder.isRecording) {
throw ArgumentError(
'"recorder" must not already be associated with another Canvas.');
@ -43,7 +42,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void saveLayer(ui.Rect? bounds, ui.Paint paint) {
assert(paint != null);
if (bounds == null) {
_saveLayerWithoutBounds(paint);
} else {
@ -99,7 +97,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void transform(Float64List matrix4) {
assert(matrix4 != null);
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
}
@ -119,8 +116,6 @@ class CanvasKitCanvas implements ui.Canvas {
void clipRect(ui.Rect rect,
{ui.ClipOp clipOp = ui.ClipOp.intersect, bool doAntiAlias = true}) {
assert(rectIsValid(rect));
assert(clipOp != null);
assert(doAntiAlias != null);
_clipRect(rect, clipOp, doAntiAlias);
}
@ -131,7 +126,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void clipRRect(ui.RRect rrect, {bool doAntiAlias = true}) {
assert(rrectIsValid(rrect));
assert(doAntiAlias != null);
_clipRRect(rrect, doAntiAlias);
}
@ -141,8 +135,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void clipPath(ui.Path path, {bool doAntiAlias = true}) {
assert(path != null); // path is checked on the engine side
assert(doAntiAlias != null);
_canvas.clipPath(path as CkPath, doAntiAlias);
}
@ -163,8 +155,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawColor(ui.Color color, ui.BlendMode blendMode) {
assert(color != null);
assert(blendMode != null);
_drawColor(color, blendMode);
}
@ -176,7 +166,6 @@ class CanvasKitCanvas implements ui.Canvas {
void drawLine(ui.Offset p1, ui.Offset p2, ui.Paint paint) {
assert(offsetIsValid(p1));
assert(offsetIsValid(p2));
assert(paint != null);
_drawLine(p1, p2, paint);
}
@ -186,7 +175,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawPaint(ui.Paint paint) {
assert(paint != null);
_drawPaint(paint);
}
@ -197,7 +185,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawRect(ui.Rect rect, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
_drawRect(rect, paint);
}
@ -208,7 +195,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawRRect(ui.RRect rrect, ui.Paint paint) {
assert(rrectIsValid(rrect));
assert(paint != null);
_drawRRect(rrect, paint);
}
@ -220,7 +206,6 @@ class CanvasKitCanvas implements ui.Canvas {
void drawDRRect(ui.RRect outer, ui.RRect inner, ui.Paint paint) {
assert(rrectIsValid(outer));
assert(rrectIsValid(inner));
assert(paint != null);
_drawDRRect(outer, inner, paint);
}
@ -231,7 +216,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawOval(ui.Rect rect, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
_drawOval(rect, paint);
}
@ -242,7 +226,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawCircle(ui.Offset c, double radius, ui.Paint paint) {
assert(offsetIsValid(c));
assert(paint != null);
_drawCircle(c, radius, paint);
}
@ -254,7 +237,6 @@ class CanvasKitCanvas implements ui.Canvas {
void drawArc(ui.Rect rect, double startAngle, double sweepAngle,
bool useCenter, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
_drawArc(rect, startAngle, sweepAngle, useCenter, paint);
}
@ -265,47 +247,37 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawPath(ui.Path path, ui.Paint paint) {
assert(path != null); // path is checked on the engine side
assert(paint != null);
_canvas.drawPath(path as CkPath, paint as CkPaint);
}
@override
void drawImage(ui.Image image, ui.Offset p, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(offsetIsValid(p));
assert(paint != null);
_canvas.drawImage(image as CkImage, p, paint as CkPaint);
}
@override
void drawImageRect(ui.Image image, ui.Rect src, ui.Rect dst, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(rectIsValid(src));
assert(rectIsValid(dst));
assert(paint != null);
_canvas.drawImageRect(image as CkImage, src, dst, paint as CkPaint);
}
@override
void drawImageNine(
ui.Image image, ui.Rect center, ui.Rect dst, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(rectIsValid(center));
assert(rectIsValid(dst));
assert(paint != null);
_canvas.drawImageNine(image as CkImage, center, dst, paint as CkPaint);
}
@override
void drawPicture(ui.Picture picture) {
assert(picture != null); // picture is checked on the engine side
_canvas.drawPicture(picture as CkPicture);
}
@override
void drawParagraph(ui.Paragraph paragraph, ui.Offset offset) {
assert(paragraph != null);
assert(offsetIsValid(offset));
_drawParagraph(paragraph, offset);
}
@ -317,9 +289,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawPoints(
ui.PointMode pointMode, List<ui.Offset> points, ui.Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
final SkFloat32List skPoints = toMallocedSkPoints(points);
_canvas.drawPoints(
paint as CkPaint,
@ -332,9 +301,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawRawPoints(
ui.PointMode pointMode, Float32List points, ui.Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
if (points.length % 2 != 0) {
throw ArgumentError('"points" must have an even number of values.');
}
@ -348,9 +314,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawVertices(
ui.Vertices vertices, ui.BlendMode blendMode, ui.Paint paint) {
assert(vertices != null); // vertices is checked on the engine side
assert(paint != null);
assert(blendMode != null);
_canvas.drawVertices(vertices as CkVertices, blendMode, paint as CkPaint);
}
@ -363,11 +326,7 @@ class CanvasKitCanvas implements ui.Canvas {
ui.BlendMode? blendMode,
ui.Rect? cullRect,
ui.Paint paint) {
assert(atlas != null); // atlas is checked on the engine side
assert(transforms != null);
assert(rects != null);
assert(colors == null || colors.isEmpty || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (transforms.length != rectCount) {
@ -415,11 +374,7 @@ class CanvasKitCanvas implements ui.Canvas {
ui.BlendMode? blendMode,
ui.Rect? cullRect,
ui.Paint paint) {
assert(atlas != null); // atlas is checked on the engine side
assert(rstTransforms != null);
assert(rects != null);
assert(colors == null || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (rstTransforms.length != rectCount) {
@ -460,9 +415,6 @@ class CanvasKitCanvas implements ui.Canvas {
@override
void drawShadow(ui.Path path, ui.Color color, double elevation,
bool transparentOccluder) {
assert(path != null); // path is checked on the engine side
assert(color != null);
assert(transparentOccluder != null);
_drawShadow(path, color, elevation, transparentOccluder);
}

View File

@ -472,7 +472,6 @@ class PictureLayer extends Layer {
@override
void paint(PaintContext paintContext) {
assert(picture != null);
assert(needsPainting);
paintContext.leafNodesCanvas!.save();

View File

@ -147,7 +147,6 @@ class LayerSceneBuilder implements ui.SceneBuilder {
ui.ColorFilter filter, {
ui.ColorFilterEngineLayer? oldLayer,
}) {
assert(filter != null);
return pushLayer<ColorFilterEngineLayer>(ColorFilterEngineLayer(filter));
}
@ -157,7 +156,6 @@ class LayerSceneBuilder implements ui.SceneBuilder {
ui.ImageFilterEngineLayer? oldLayer,
ui.Offset offset = ui.Offset.zero,
}) {
assert(filter != null);
return pushLayer<ImageFilterEngineLayer>(ImageFilterEngineLayer(filter, offset));
}

View File

@ -86,7 +86,6 @@ class CkPath extends ManagedSkiaObject<SkPath> implements ui.Path {
@override
void addPolygon(List<ui.Offset> points, bool close) {
assert(points != null);
final SkFloat32List encodedPoints = toMallocedSkPoints(points);
skiaObject.addPoly(encodedPoints.toTypedArray(), close);
free(encodedPoints);

View File

@ -47,10 +47,6 @@ class CkGradientSweep extends CkShader implements ui.Gradient {
CkGradientSweep(this.center, this.colors, this.colorStops, this.tileMode,
this.startAngle, this.endAngle, this.matrix4)
: assert(offsetIsValid(center)),
assert(colors != null),
assert(tileMode != null),
assert(startAngle != null),
assert(endAngle != null),
assert(startAngle < endAngle),
assert(matrix4 == null || matrix4IsValid(matrix4)) {
validateColorStops(colors, colorStops);
@ -96,8 +92,6 @@ class CkGradientLinear extends CkShader implements ui.Gradient {
Float32List? matrix,
) : assert(offsetIsValid(from)),
assert(offsetIsValid(to)),
assert(colors != null),
assert(tileMode != null),
matrix4 = matrix {
if (assertionsEnabled) {
assert(matrix4 == null || matrix4IsValid(matrix4!));

View File

@ -26,9 +26,7 @@ typedef SubmitCallback = bool Function(SurfaceFrame, CkCanvas);
/// A frame which contains a canvas to be drawn into.
class SurfaceFrame {
SurfaceFrame(this.skiaSurface, this.submitCallback)
: _submitted = false,
assert(skiaSurface != null),
assert(submitCallback != null);
: _submitted = false;
final CkSurface skiaSurface;
final SubmitCallback submitCallback;

View File

@ -18,8 +18,6 @@ class CkVertices extends ManagedSkiaObject<SkVertices> implements ui.Vertices {
List<ui.Color>? colors,
List<int>? indices,
}) {
assert(mode != null);
assert(positions != null);
if (textureCoordinates != null &&
textureCoordinates.length != positions.length) {
throw ArgumentError(
@ -50,8 +48,6 @@ class CkVertices extends ManagedSkiaObject<SkVertices> implements ui.Vertices {
Int32List? colors,
Uint16List? indices,
}) {
assert(mode != null);
assert(positions != null);
if (textureCoordinates != null &&
textureCoordinates.length != positions.length) {
throw ArgumentError(

View File

@ -38,8 +38,7 @@ class BitmapCanvas extends EngineCanvas {
/// initialize this canvas.
BitmapCanvas(this._bounds, RenderStrategy renderStrategy,
{double density = 1.0})
: assert(_bounds != null),
_density = density,
: _density = density,
_renderStrategy = renderStrategy,
widthInBitmapPixels = widthToPhysical(_bounds.width),
heightInBitmapPixels = heightToPhysical(_bounds.height),
@ -69,7 +68,6 @@ class BitmapCanvas extends EngineCanvas {
/// Painting outside these bounds will result in cropping.
ui.Rect get bounds => _bounds;
set bounds(ui.Rect newValue) {
assert(newValue != null);
_bounds = newValue;
final int newCanvasPositionX = _bounds.left.floor() - kPaddingPixels;
final int newCanvasPositionY = _bounds.top.floor() - kPaddingPixels;
@ -217,7 +215,6 @@ class BitmapCanvas extends EngineCanvas {
// Used by picture to assess if canvas is large enough to reuse as is.
bool doesFitBounds(ui.Rect newBounds, double newDensity) {
assert(newBounds != null);
return widthInBitmapPixels >= widthToPhysical(newBounds.width) &&
heightInBitmapPixels >= heightToPhysical(newBounds.height) &&
_density == newDensity;
@ -1334,7 +1331,6 @@ String? stringForStrokeCap(ui.StrokeCap? strokeCap) {
}
String stringForStrokeJoin(ui.StrokeJoin strokeJoin) {
assert(strokeJoin != null);
switch (strokeJoin) {
case ui.StrokeJoin.round:
return 'round';

View File

@ -36,7 +36,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void saveLayer(ui.Rect? bounds, ui.Paint paint) {
assert(paint != null);
if (bounds == null) {
_saveLayerWithoutBounds(paint);
} else {
@ -90,7 +89,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void transform(Float64List matrix4) {
assert(matrix4 != null);
if (matrix4.length != 16) {
throw ArgumentError('"matrix4" must have 16 entries.');
}
@ -110,8 +108,6 @@ class SurfaceCanvas implements ui.Canvas {
void clipRect(ui.Rect rect,
{ui.ClipOp clipOp = ui.ClipOp.intersect, bool doAntiAlias = true}) {
assert(rectIsValid(rect));
assert(clipOp != null);
assert(doAntiAlias != null);
_clipRect(rect, clipOp, doAntiAlias);
}
@ -122,7 +118,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void clipRRect(ui.RRect rrect, {bool doAntiAlias = true}) {
assert(rrectIsValid(rrect));
assert(doAntiAlias != null);
_clipRRect(rrect, doAntiAlias);
}
@ -132,8 +127,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void clipPath(ui.Path path, {bool doAntiAlias = true}) {
assert(path != null); // path is checked on the engine side
assert(doAntiAlias != null);
_clipPath(path, doAntiAlias);
}
@ -171,8 +164,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawColor(ui.Color color, ui.BlendMode blendMode) {
assert(color != null);
assert(blendMode != null);
_drawColor(color, blendMode);
}
@ -184,7 +175,6 @@ class SurfaceCanvas implements ui.Canvas {
void drawLine(ui.Offset p1, ui.Offset p2, ui.Paint paint) {
assert(offsetIsValid(p1));
assert(offsetIsValid(p2));
assert(paint != null);
_drawLine(p1, p2, paint);
}
@ -194,7 +184,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawPaint(ui.Paint paint) {
assert(paint != null);
_drawPaint(paint);
}
@ -205,7 +194,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawRect(ui.Rect rect, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
_drawRect(rect, paint);
}
@ -216,7 +204,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawRRect(ui.RRect rrect, ui.Paint paint) {
assert(rrectIsValid(rrect));
assert(paint != null);
_drawRRect(rrect, paint);
}
@ -228,7 +215,6 @@ class SurfaceCanvas implements ui.Canvas {
void drawDRRect(ui.RRect outer, ui.RRect inner, ui.Paint paint) {
assert(rrectIsValid(outer));
assert(rrectIsValid(inner));
assert(paint != null);
_drawDRRect(outer, inner, paint);
}
@ -239,7 +225,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawOval(ui.Rect rect, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
_drawOval(rect, paint);
}
@ -250,7 +235,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawCircle(ui.Offset c, double radius, ui.Paint paint) {
assert(offsetIsValid(c));
assert(paint != null);
_drawCircle(c, radius, paint);
}
@ -262,7 +246,6 @@ class SurfaceCanvas implements ui.Canvas {
void drawArc(ui.Rect rect, double startAngle, double sweepAngle,
bool useCenter, ui.Paint paint) {
assert(rectIsValid(rect));
assert(paint != null);
const double pi = math.pi;
const double pi2 = 2.0 * pi;
@ -297,8 +280,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawPath(ui.Path path, ui.Paint paint) {
assert(path != null); // path is checked on the engine side
assert(paint != null);
_drawPath(path, paint);
}
@ -308,9 +289,7 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawImage(ui.Image image, ui.Offset offset, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(offsetIsValid(offset));
assert(paint != null);
_drawImage(image, offset, paint);
}
@ -320,10 +299,8 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawImageRect(ui.Image image, ui.Rect src, ui.Rect dst, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(rectIsValid(src));
assert(rectIsValid(dst));
assert(paint != null);
_drawImageRect(image, src, dst, paint);
}
@ -376,10 +353,8 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawImageNine(
ui.Image image, ui.Rect center, ui.Rect dst, ui.Paint paint) {
assert(image != null); // image is checked on the engine side
assert(rectIsValid(center));
assert(rectIsValid(dst));
assert(paint != null);
if (dst.isEmpty) {
return;
@ -424,13 +399,11 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawPicture(ui.Picture picture) {
assert(picture != null); // picture is checked on the engine side
_canvas.drawPicture(picture);
}
@override
void drawParagraph(ui.Paragraph paragraph, ui.Offset offset) {
assert(paragraph != null);
assert(offsetIsValid(offset));
_drawParagraph(paragraph, offset);
}
@ -442,9 +415,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawPoints(
ui.PointMode pointMode, List<ui.Offset> points, ui.Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
final Float32List pointList = offsetListToFloat32List(points);
drawRawPoints(pointMode, pointList, paint);
}
@ -452,9 +422,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawRawPoints(
ui.PointMode pointMode, Float32List points, ui.Paint paint) {
assert(pointMode != null);
assert(points != null);
assert(paint != null);
if (points.length % 2 != 0) {
throw ArgumentError('"points" must have an even number of values.');
}
@ -464,9 +431,6 @@ class SurfaceCanvas implements ui.Canvas {
@override
void drawVertices(
ui.Vertices vertices, ui.BlendMode blendMode, ui.Paint paint) {
//assert(vertices != null); // vertices is checked on the engine side
assert(paint != null);
assert(blendMode != null);
_canvas.drawVertices(
vertices as SurfaceVertices, blendMode, paint as SurfacePaint);
}
@ -481,11 +445,7 @@ class SurfaceCanvas implements ui.Canvas {
ui.Rect? cullRect,
ui.Paint paint,
) {
assert(atlas != null); // atlas is checked on the engine side
assert(transforms != null);
assert(rects != null);
assert(colors == null || colors.isEmpty || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (transforms.length != rectCount) {
@ -510,11 +470,7 @@ class SurfaceCanvas implements ui.Canvas {
ui.Rect? cullRect,
ui.Paint paint,
) {
assert(atlas != null); // atlas is checked on the engine side
assert(rstTransforms != null);
assert(rects != null);
assert(colors == null || blendMode != null);
assert(paint != null);
final int rectCount = rects.length;
if (rstTransforms.length != rectCount) {
@ -540,9 +496,6 @@ class SurfaceCanvas implements ui.Canvas {
double elevation,
bool transparentOccluder,
) {
assert(path != null); // path is checked on the engine side
assert(color != null);
assert(transparentOccluder != null);
_canvas.drawShadow(path, color, elevation, transparentOccluder);
}
}

View File

@ -257,8 +257,7 @@ DomHTMLElement buildDrawRectElement(
..transformOrigin = '0 0 0'
..transform = effectiveTransform;
String cssColor =
paint.color == null ? '#000000' : colorValueToCssString(paint.color)!;
String cssColor = colorValueToCssString(paint.color)!;
if (paint.maskFilter != null) {
final double sigma = paint.maskFilter!.webOnlySigma;
@ -352,10 +351,8 @@ SVGSVGElement pathToSvgElement(SurfacePath path, SurfacePaintData paint) {
svgPath.setAttribute('stroke-linecap', '${stringForStrokeCap(paint.strokeCap)}');
}
svgPath.setAttribute('fill', 'none');
} else if (paint.color != null) {
svgPath.setAttribute('fill', colorValueToCssString(paint.color)!);
} else {
svgPath.setAttribute('fill', '#000000');
svgPath.setAttribute('fill', colorValueToCssString(paint.color)!);
}
if (path.fillType == ui.PathFillType.evenOdd) {
svgPath.setAttribute('fill-rule', 'evenodd');

View File

@ -161,7 +161,7 @@ class SurfacePaint implements ui.Paint {
@override
set strokeMiterLimit(double value) {
assert(value != null);
}
@override
@ -268,9 +268,7 @@ class SurfacePaintData {
if (strokeJoin != null) {
buffer.write('strokeJoin = $strokeJoin; ');
}
if (color != null) {
buffer.write('color = ${colorToCssString(ui.Color(color))}; ');
}
buffer.write('color = ${colorToCssString(ui.Color(color))}; ');
if (shader != null) {
buffer.write('shader = $shader; ');
}

View File

@ -54,8 +54,7 @@ class PaintRequest {
PaintRequest({
required this.canvasSize,
required this.paintCallback,
}) : assert(canvasSize != null),
assert(paintCallback != null);
});
final ui.Size canvasSize;
final ui.VoidCallback paintCallback;

View File

@ -26,9 +26,7 @@ class SurfaceVertices implements ui.Vertices {
List<ui.Offset> positions, {
List<ui.Color>? colors,
List<int>? indices,
}) : assert(mode != null),
assert(positions != null),
colors = colors != null ? _int32ListFromColors(colors) : null,
}) : colors = colors != null ? _int32ListFromColors(colors) : null,
indices = indices != null ? Uint16List.fromList(indices) : null,
positions = offsetListToFloat32List(positions) {
initWebGl();
@ -39,8 +37,7 @@ class SurfaceVertices implements ui.Vertices {
this.positions, {
this.colors,
this.indices,
}) : assert(mode != null),
assert(positions != null) {
}) {
initWebGl();
}
@ -192,7 +189,6 @@ class _WebGlRenderer implements GlRenderer {
//
// Create buffer for vertex coordinates.
final Object positionsBuffer = gl.createBuffer()!;
assert(positionsBuffer != null);
Object? vao;
if (imageShader != null) {
@ -383,7 +379,6 @@ class _WebGlRenderer implements GlRenderer {
// Setup geometry.
final Object positionsBuffer = gl.createBuffer()!;
assert(positionsBuffer != null);
gl.bindArrayBuffer(positionsBuffer);
gl.bufferData(vertices, gl.kStaticDraw);
// Point an attribute to the currently bound vertex buffer object.
@ -458,7 +453,6 @@ class _WebGlRenderer implements GlRenderer {
@override
void drawHairline(
DomCanvasRenderingContext2D? ctx, Float32List positions) {
assert(positions != null);
final int pointCount = positions.length ~/ 2;
ctx!.lineWidth = 1.0;
ctx.beginPath();

View File

@ -136,7 +136,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
ui.Clip clipBehavior = ui.Clip.antiAlias,
ui.ClipRectEngineLayer? oldLayer,
}) {
assert(clipBehavior != null);
return _pushSurface<PersistedClipRect>(
PersistedClipRect(oldLayer as PersistedClipRect?, rect, clipBehavior));
}
@ -167,7 +166,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
ui.Clip clipBehavior = ui.Clip.antiAlias,
ui.ClipPathEngineLayer? oldLayer,
}) {
assert(clipBehavior != null);
return _pushSurface<PersistedClipPath>(
PersistedClipPath(oldLayer as PersistedClipPath?, path, clipBehavior));
}
@ -205,7 +203,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
ui.ColorFilter filter, {
ui.ColorFilterEngineLayer? oldLayer,
}) {
assert(filter != null);
return _pushSurface<PersistedColorFilter>(
PersistedColorFilter(oldLayer as PersistedColorFilter?, filter));
}
@ -226,7 +223,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
ui.Offset offset = ui.Offset.zero,
ui.ImageFilterEngineLayer? oldLayer,
}) {
assert(filter != null);
return _pushSurface<PersistedImageFilter>(
PersistedImageFilter(oldLayer as PersistedImageFilter?, filter, offset));
}
@ -264,7 +260,6 @@ class SurfaceSceneBuilder implements ui.SceneBuilder {
ui.ShaderMaskEngineLayer? oldLayer,
ui.FilterQuality filterQuality = ui.FilterQuality.low,
}) {
assert(blendMode != null);
return _pushSurface<PersistedShaderMask>(PersistedShaderMask(
oldLayer as PersistedShaderMask?,
shader, maskRect, blendMode, filterQuality));

View File

@ -187,7 +187,6 @@ class EngineImageShader implements ui.ImageShader {
///
/// Create buffer for vertex coordinates.
final Object positionsBuffer = gl.createBuffer()!;
assert(positionsBuffer != null);
Object? vao;
if (isWebGl2) {

View File

@ -69,11 +69,6 @@ class GradientSweep extends EngineGradient {
GradientSweep(this.center, this.colors, this.colorStops, this.tileMode,
this.startAngle, this.endAngle, this.matrix4)
: assert(offsetIsValid(center)),
assert(colors != null),
assert(tileMode != null),
assert(startAngle != null),
assert(endAngle != null),
assert(startAngle < endAngle),
super._() {
validateColorStops(colors, colorStops);
}
@ -189,8 +184,6 @@ class GradientLinear extends EngineGradient {
Float32List? matrix,
) : assert(offsetIsValid(from)),
assert(offsetIsValid(to)),
assert(colors != null),
assert(tileMode != null),
matrix4 = matrix == null ? null : FastMatrix32(matrix),
super._() {
if (assertionsEnabled) {

View File

@ -223,7 +223,6 @@ abstract class PersistedSurface implements ui.EngineLayer {
/// surface.
PersistedSurfaceState get state => _state;
set state(PersistedSurfaceState newState) {
assert(newState != null);
assert(newState != _state,
'Attempted to set state that the surface is already in. This likely indicates a bug in the compositor.');
assert(_debugValidateStateTransition(newState));
@ -414,7 +413,6 @@ abstract class PersistedSurface implements ui.EngineLayer {
/// creates a new element by calling [build].
@mustCallSuper
void update(covariant PersistedSurface oldSurface) {
assert(oldSurface != null);
assert(!identical(oldSurface, this));
assert(debugAssertSurfaceState(this, PersistedSurfaceState.created));
assert(debugAssertSurfaceState(oldSurface, PersistedSurfaceState.active,
@ -1049,7 +1047,6 @@ abstract class PersistedContainerSurface extends PersistedSurface {
final PersistedSurface child = _children[i];
final DomHTMLElement childElement =
child.rootElement! as DomHTMLElement;
assert(childElement != null);
if (!isStationary) {
if (refNode == null) {
containerElement!.append(childElement);

View File

@ -237,7 +237,6 @@ void debugPrintSurfaceStats(PersistedScene scene, int frameNumber) {
void countReusesRecursively(PersistedSurface surface) {
final DebugSurfaceStats stats = surfaceStatsFor(surface);
assert(stats != null);
surfaceRetainCount += stats.retainSurfaceCount;
elementReuseCount += stats.reuseElementCount;

View File

@ -252,7 +252,6 @@ AssetManager get assetManager => _assetManager!;
AssetManager? _assetManager;
void _setAssetManager(AssetManager assetManager) {
assert(assetManager != null, 'Cannot set assetManager to null');
if (assetManager == _assetManager) {
return;
}

View File

@ -359,7 +359,6 @@ class SingleEntryBrowserHistory extends BrowserHistory {
/// replaces the state of the entry so that we can recognize it later using
/// [_isOriginEntry] inside [_popStateListener].
void _setupOriginEntry(UrlStrategy strategy) {
assert(strategy != null);
strategy.replaceState(_wrapOriginState(currentState), 'origin', '');
}
@ -370,7 +369,6 @@ class SingleEntryBrowserHistory extends BrowserHistory {
bool replace = false,
String? path,
}) {
assert(strategy != null);
path ??= currentPath;
if (replace) {
strategy.replaceState(_flutterState, 'flutter', path);

View File

@ -817,9 +817,6 @@ class _PointerAdapter extends _BaseAdapter with _WheelEventListenerMixin {
required DomPointerEvent event,
required _SanitizedDetails details,
}) {
assert(data != null);
assert(event != null);
assert(details != null);
final ui.PointerDeviceKind kind = _pointerTypeToDeviceKind(event.pointerType!);
final double tilt = _computeHighestTilt(event);
final Duration timeStamp = _BaseAdapter._eventTimeStampToDuration(event.timeStamp!);
@ -1147,9 +1144,6 @@ class _MouseAdapter extends _BaseAdapter with _WheelEventListenerMixin {
required DomMouseEvent event,
required _SanitizedDetails details,
}) {
assert(data != null);
assert(event != null);
assert(details != null);
final ui.Offset offset = computeEventOffsetToTarget(event, glassPaneElement);
_pointerDataConverter.convert(
data,

View File

@ -240,7 +240,6 @@ class PointerDataConverter {
print('>> device=$device change=$change buttons=$buttons');
}
final bool isDown = buttons != 0;
assert(change != null);
if (signalKind == null ||
signalKind == ui.PointerSignalKind.none) {
switch (change) {

View File

@ -381,8 +381,7 @@ abstract class RoleManager {
/// Initializes a role for [semanticsObject].
///
/// A single role object manages exactly one [SemanticsObject].
RoleManager(this.role, this.semanticsObject)
: assert(semanticsObject != null);
RoleManager(this.role, this.semanticsObject);
/// Role identifier.
final Role role;
@ -869,7 +868,6 @@ class SemanticsObject {
void updateSelf(SemanticsNodeUpdate update) {
// Update all field values and their corresponding dirty flags before
// applying the updates to the DOM.
assert(update.flags != null);
if (_flags != update.flags) {
_flags = update.flags;
_markFlagsDirty();
@ -1478,8 +1476,6 @@ class EngineSemanticsOwner {
/// allows the same node to be detached from one parent in the tree and
/// reattached to another parent.
void _attachObject({required SemanticsObject parent, required SemanticsObject child}) {
assert(child != null);
assert(parent != null);
child._parent = parent;
_attachments[child.id] = parent;
}
@ -1616,13 +1612,7 @@ class EngineSemanticsOwner {
/// the Web Engine.
///
/// The default mode is [AccessibilityMode.unknown].
AccessibilityMode get mode => _mode;
set mode(AccessibilityMode value) {
assert(value != null);
_mode = value;
}
AccessibilityMode _mode = AccessibilityMode.unknown;
AccessibilityMode mode = AccessibilityMode.unknown;
/// Currently used [GestureMode].
///
@ -1764,7 +1754,7 @@ class EngineSemanticsOwner {
/// not accompanied by pointer events. In the presence of pointer events,
/// delegate to Flutter's gesture detection system to produce gestures.
bool shouldAcceptBrowserGesture(String eventType) {
if (_mode == AccessibilityMode.known) {
if (mode == AccessibilityMode.known) {
// Do not ignore accessibility gestures in known mode, unless semantics
// is explicitly disabled.
return semanticsEnabled;

View File

@ -212,8 +212,6 @@ abstract class _TypedDataBuffer<E> extends ListBase<E> {
/// Like [insertAll], but with a guaranteed non-`null` [start] and [end].
void _insertKnownLength(int index, Iterable<E> values, int start, int end) {
assert(values != null);
assert(end != null);
if (start > values.length || end > values.length) {
throw StateError('Too few elements');
}

View File

@ -32,7 +32,7 @@ abstract class MessageCodec<T> {
class MethodCall {
/// Creates a [MethodCall] representing the invocation of [method] with the
/// specified [arguments].
const MethodCall(this.method, [this.arguments]) : assert(method != null);
const MethodCall(this.method, [this.arguments]);
/// The name of the method to be called.
final String method;
@ -101,7 +101,7 @@ class PlatformException implements Exception {
required this.code,
this.message,
this.details,
}) : assert(code != null);
});
/// An error code.
final String code;

View File

@ -160,7 +160,6 @@ class JSONMethodCodec implements MethodCodec {
@override
ByteData? encodeErrorEnvelope(
{required String code, String? message, dynamic details}) {
assert(code != null);
return const JSONMessageCodec()
.encodeMessage(<dynamic>[code, message, details]);
}

View File

@ -122,7 +122,7 @@ class WriteBuffer {
/// The byte order used is [Endian.host] throughout.
class ReadBuffer {
/// Creates a [ReadBuffer] for reading from the specified [data].
ReadBuffer(this.data) : assert(data != null);
ReadBuffer(this.data);
/// The underlying data being read.
final ByteData data;

View File

@ -778,8 +778,6 @@ void applyTextStyleToElement({
required DomElement element,
required EngineTextStyle style,
}) {
assert(element != null);
assert(style != null);
bool updateDecoration = false;
final DomCSSStyleDeclaration cssStyle = element.style;

View File

@ -360,7 +360,6 @@ class AutofillInfo {
factory AutofillInfo.fromFrameworkMessage(Map<String, dynamic> autofill,
{TextCapitalizationConfig textCapitalization =
const TextCapitalizationConfig.defaultCapitalization()}) {
assert(autofill != null);
final String uniqueIdentifier = autofill.readString('uniqueIdentifier');
final List<dynamic>? hintsList = autofill.tryList('hints');
final String? firstHint = (hintsList == null || hintsList.isEmpty) ? null : hintsList.first as String;

View File

@ -7,7 +7,6 @@ import 'dart:typed_data';
import 'package:ui/ui.dart' as ui;
bool rectIsValid(ui.Rect rect) {
assert(rect != null, 'Rect argument was null.');
assert(
!(rect.left.isNaN ||
rect.right.isNaN ||
@ -18,7 +17,6 @@ bool rectIsValid(ui.Rect rect) {
}
bool rrectIsValid(ui.RRect rrect) {
assert(rrect != null, 'RRect argument was null.');
assert(
!(rrect.left.isNaN ||
rrect.right.isNaN ||
@ -29,20 +27,17 @@ bool rrectIsValid(ui.RRect rrect) {
}
bool offsetIsValid(ui.Offset offset) {
assert(offset != null, 'Offset argument was null.');
assert(!offset.dx.isNaN && !offset.dy.isNaN,
'Offset argument contained a NaN value.');
return true;
}
bool matrix4IsValid(Float32List matrix4) {
assert(matrix4 != null, 'Matrix4 argument was null.');
assert(matrix4.length == 16, 'Matrix4 must have 16 entries.');
return true;
}
bool radiusIsValid(ui.Radius radius) {
assert(radius != null, 'Radius argument was null.');
assert(!radius.x.isNaN && !radius.y.isNaN,
'Radius argument contained a NaN value.');
return true;

View File

@ -45,7 +45,6 @@ class FontWeight {
w900
];
static FontWeight? lerp(FontWeight? a, FontWeight? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
@ -75,10 +74,8 @@ class FontWeight {
class FontFeature {
const FontFeature(this.feature, [this.value = 1])
: assert(feature != null),
assert(feature.length == 4,
: assert(feature.length == 4,
'Feature tag must be exactly four characters long.'),
assert(value != null),
assert(value >= 0, 'Feature value must be zero or a positive integer.');
const FontFeature.enable(String feature) : this(feature, 1);
const FontFeature.disable(String feature) : this(feature, 0);
@ -184,9 +181,7 @@ class FontVariation {
const FontVariation(
this.axis,
this.value,
) : assert(axis != null),
assert(axis.length == 4, 'Axis tag must be exactly four characters long.'),
assert(value != null);
) : assert(axis.length == 4, 'Axis tag must be exactly four characters long.');
final String axis;
final double value;
@ -519,8 +514,7 @@ class TextPosition {
const TextPosition({
required this.offset,
this.affinity = TextAffinity.downstream,
}) : assert(offset != null),
assert(affinity != null);
});
final int offset;
final TextAffinity affinity;
@ -595,7 +589,7 @@ class TextRange {
class ParagraphConstraints {
const ParagraphConstraints({
required this.width,
}) : assert(width != null);
});
final double width;
@override

View File

@ -158,8 +158,7 @@ enum Brightness {
// Unimplemented classes.
// TODO(dit): see https://github.com/flutter/flutter/issues/33614.
class CallbackHandle {
CallbackHandle.fromRawHandle(this._handle)
: assert(_handle != null, "'_handle' must not be null.");
CallbackHandle.fromRawHandle(this._handle);
final int _handle;

View File

@ -76,7 +76,6 @@ void main() {
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
expect(scene != null, true);
await scene.toImage(100, 100);
});
@ -108,7 +107,6 @@ void main() {
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
expect(scene != null, true);
await scene.toImage(100, 100);
});

View File

@ -27,23 +27,15 @@ void main() {
});
test('color created with out of bounds value', () {
try {
const Color c = Color(0x100 << 24);
final Paint p = Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
const Color c = Color(0x100 << 24);
final Paint p = Paint();
p.color = c;
});
test('color created with wildly out of bounds value', () {
try {
const Color c = Color(1 << 1000000);
final Paint p = Paint();
p.color = c;
} catch (e) {
expect(e != null, equals(true));
}
const Color c = Color(1 << 1000000);
final Paint p = Paint();
p.color = c;
});
test('two colors are only == if they have the same runtime type', () {

View File

@ -83,7 +83,6 @@ void main() {
}
final Scene scene = builder.build();
expect(scene != null, true);
scene.dispose();
});

View File

@ -22,7 +22,6 @@ void main() {
builder.addPicture(Offset.zero, picture);
final Scene scene = builder.build();
expect(scene != null, true);
await scene.toImage(100, 100);
});
}

View File

@ -12,7 +12,6 @@ import 'dart:ui';
import 'src/scenarios.dart';
void main() {
assert(window.locale != null);
window
..onPlatformMessage = _handlePlatformMessage
..onBeginFrame = _onBeginFrame

View File

@ -17,8 +17,7 @@ class AnimatedColorSquareScenario extends Scenario {
///
/// The [dispatcher] parameter must not be null.
AnimatedColorSquareScenario(PlatformDispatcher dispatcher)
: assert(dispatcher != null),
super(dispatcher);
: super(dispatcher);
static const double _squareSize = 200;
/// Used to animate the red value in the color of the square.
@ -77,9 +76,7 @@ class AnimatedColorSquareScenario extends Scenario {
class _NumberSwinger<T extends num> {
_NumberSwinger(this._begin, this._end, [T? current])
: assert(_begin != null),
assert(_end != null),
_up = _begin < _end {
: _up = _begin < _end {
_current = current ?? _begin;
}

View File

@ -14,8 +14,7 @@ class BogusFontText extends Scenario {
///
/// The [dispatcher] parameter must not be null.
BogusFontText(PlatformDispatcher dispatcher)
: assert(dispatcher != null),
super(dispatcher);
: super(dispatcher);
// Semi-arbitrary.
final double _screenWidth = 700;

View File

@ -14,8 +14,7 @@ class InitialRouteReply extends Scenario {
///
/// The [window] parameter must not be null.
InitialRouteReply(PlatformDispatcher dispatcher)
: assert(dispatcher != null),
super(dispatcher);
: super(dispatcher);
@override
void onBeginFrame(Duration duration) {

View File

@ -13,8 +13,7 @@ import 'scenario.dart';
class LocaleInitialization extends Scenario {
/// Constructor
LocaleInitialization(PlatformDispatcher dispatcher)
: assert(dispatcher != null),
super(dispatcher);
: super(dispatcher);
int _tapCount = 0;

View File

@ -44,8 +44,7 @@ class PlatformViewScenario extends Scenario
PlatformViewScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -71,8 +70,7 @@ class NonFullScreenFlutterViewPlatformViewScenario extends Scenario
NonFullScreenFlutterViewPlatformViewScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -98,8 +96,7 @@ class PlatformViewNoOverlayIntersectionScenario extends Scenario
PlatformViewNoOverlayIntersectionScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -133,8 +130,7 @@ class PlatformViewLargerThanDisplaySize extends Scenario
PlatformViewLargerThanDisplaySize(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -166,8 +162,7 @@ class PlatformViewPartialIntersectionScenario extends Scenario
PlatformViewPartialIntersectionScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier .
final int id;
@ -198,8 +193,7 @@ class PlatformViewTwoIntersectingOverlaysScenario extends Scenario
PlatformViewTwoIntersectingOverlaysScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -242,8 +236,7 @@ class PlatformViewOneOverlayTwoIntersectingOverlaysScenario extends Scenario
PlatformViewOneOverlayTwoIntersectingOverlaysScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -293,8 +286,7 @@ class MultiPlatformViewWithoutOverlaysScenario extends Scenario
PlatformDispatcher dispatcher, {
required this.firstId,
required this.secondId,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier to use for the first platform view.
final int firstId;
@ -349,8 +341,7 @@ class PlatformViewMaxOverlaysScenario extends Scenario
PlatformViewMaxOverlaysScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -404,8 +395,7 @@ class MultiPlatformViewScenario extends Scenario
PlatformDispatcher dispatcher, {
required this.firstId,
required this.secondId,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier to use for the first platform view.
final int firstId;
@ -453,8 +443,7 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
PlatformDispatcher dispatcher, {
required this.firstId,
required this.secondId,
}) : assert(dispatcher != null),
super(dispatcher) {
}) : super(dispatcher) {
_nextFrame = _firstFrame;
}
@ -564,8 +553,7 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
PlatformViewClipRectScenario(
PlatformDispatcher dispatcher, {
required this.id,
}) : assert(dispatcher != null),
super(dispatcher);
}) : super(dispatcher);
/// The platform view identifier.
final int id;
@ -913,8 +901,7 @@ class PlatformViewForTouchIOSScenario extends Scenario
this.id = 0,
this.rejectUntilTouchesEnded = false,
required this.accept,
}) : assert(dispatcher != null),
super(dispatcher) {
}) : super(dispatcher) {
_nextFrame = _firstFrame;
}
@ -1222,7 +1209,6 @@ class PlatformViewScrollingUnderWidget extends Scenario
required int lastPlatformViewId,
}) : _firstPlatformViewId = firstPlatformViewId,
_lastPlatformViewId = lastPlatformViewId,
assert(dispatcher != null),
super(dispatcher);
final int _firstPlatformViewId;

View File

@ -15,8 +15,7 @@ class PoppableScreenScenario extends Scenario with PlatformEchoMixin {
///
/// The [dispatcher] parameter must not be null.
PoppableScreenScenario(PlatformDispatcher dispatcher)
: assert(dispatcher != null),
super(dispatcher);
: super(dispatcher);
// Rect for the pop button. Only defined once onMetricsChanged is called.
Rect? _buttonRect;

View File

@ -340,7 +340,6 @@ abstract class License {
body = reformat(body);
}
final License result;
assert(type != null);
switch (type) {
case LicenseType.bsd:
case LicenseType.mit:
@ -1036,7 +1035,6 @@ Iterable<_LicenseMatch> _tryInline(String body, RegExp pattern, {
required bool needsCopyright,
required String origin,
}) sync* {
assert(needsCopyright != null);
for (final _PartialLicenseMatch match in _findLicenseBlocks(body, pattern, 1, 2, needsCopyright: needsCopyright)) {
yield _LicenseMatch(License.fromBody(match.getEntireLicense(), origin: origin), match.start, match.end, debug: '_tryInline', missingCopyrights: needsCopyright && !match.hasCopyrights);
}
@ -1181,7 +1179,7 @@ License? interpretAsRedirectLicense(String fileContents, LicenseSource parentDir
final Match? match = pattern.pattern!.matchAsPrefix(body);
if (match != null && match.start == 0 && match.end == body.length) {
final License candidate = _dereferenceLicense(3, match.group as String? Function(int?), pattern, parentDirectory, origin: origin);
if (result != null && candidate != null) {
if (result != null) {
throw 'Multiple potential matches in interpretAsRedirectLicense in $parentDirectory; body was:\n------8<------\n$fileContents\n------8<------';
}
result = candidate;

View File

@ -98,7 +98,7 @@ class _RepositorySourceFile extends _RepositoryLicensedFile {
@override
Iterable<Assignment> assignLicenses() {
_internalLicenses ??= determineLicensesFor(_contents, name, parent, origin: io.fullName);
final List<License> licenses = _internalLicenses!;
final List<License>? licenses = _internalLicenses;
if (licenses != null && licenses.isNotEmpty) {
return licenses.map((License license) => license.assignLicenses(io.fullName, parent!));
}
@ -964,7 +964,6 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
} else if (entry is fs.File) {
try {
final _RepositoryFile child = createFile(entry);
assert(child != null);
if (child is _RepositoryLicensedFile) {
_files.add(child);
} else {
@ -1080,11 +1079,7 @@ class _RepositoryDirectory extends _RepositoryEntry implements LicenseSource {
return const <License>[];
}
return _licenses.expand((_RepositoryLicenseFile license) {
final List<License> licenses = license.licensesFor(name);
if (licenses != null) {
return licenses;
}
return const <License>[];
return license.licensesFor(name);
}).toList();
}
@ -1841,7 +1836,6 @@ class _Progress {
}
void advance({required bool success}) {
assert(success != null);
if (success) {
_withLicense += 1;
} else {
@ -1904,9 +1898,7 @@ String? _readSignature(String goldenPath) {
/// Writes a signature to an [system.IOSink] in the expected format.
void _writeSignature(String signature, system.IOSink sink) {
if (signature != null) {
sink.writeln('Signature: $signature\n');
}
sink.writeln('Signature: $signature\n');
}
// Checks for changes to the license tool itself.

View File

@ -111,7 +111,7 @@ void main(List<String> arguments) {
if (results['ui'] as bool) {
replacementPatterns = uiPatterns;
} else {
libraryName = results['library-name'] as String;
libraryName = results['library-name'] as String?;
if (libraryName == null) {
throw Exception('library-name must be specified if not rewriting ui');
}