Unverified Commit 5d74b5cb authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in flutter/painting (#118925)

parent c757df3b
......@@ -19,9 +19,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
/// Creates an object that fetches the image at the given URL.
///
/// The arguments [url] and [scale] must not be null.
const NetworkImage(this.url, { this.scale = 1.0, this.headers })
: assert(url != null),
assert(scale != null);
const NetworkImage(this.url, { this.scale = 1.0, this.headers });
@override
final String url;
......
......@@ -39,9 +39,7 @@ class NetworkImage
/// Creates an object that fetches the image at the given URL.
///
/// The arguments [url] and [scale] must not be null.
const NetworkImage(this.url, {this.scale = 1.0, this.headers})
: assert(url != null),
assert(scale != null);
const NetworkImage(this.url, {this.scale = 1.0, this.headers});
@override
final String url;
......
......@@ -87,7 +87,6 @@ abstract class AlignmentGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static AlignmentGeometry? lerp(AlignmentGeometry? a, AlignmentGeometry? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -188,9 +187,7 @@ class Alignment extends AlignmentGeometry {
/// Creates an alignment.
///
/// The [x] and [y] arguments must not be null.
const Alignment(this.x, this.y)
: assert(x != null),
assert(y != null);
const Alignment(this.x, this.y);
/// The distance fraction in the horizontal direction.
///
......@@ -340,7 +337,6 @@ class Alignment extends AlignmentGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static Alignment? lerp(Alignment? a, Alignment? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -407,9 +403,7 @@ class AlignmentDirectional extends AlignmentGeometry {
/// Creates a directional alignment.
///
/// The [start] and [y] arguments must not be null.
const AlignmentDirectional(this.start, this.y)
: assert(start != null),
assert(y != null);
const AlignmentDirectional(this.start, this.y);
/// The distance fraction in the horizontal direction.
///
......@@ -534,7 +528,6 @@ class AlignmentDirectional extends AlignmentGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static AlignmentDirectional? lerp(AlignmentDirectional? a, AlignmentDirectional? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -682,8 +675,7 @@ class TextAlignVertical {
/// Creates a TextAlignVertical from any y value between -1.0 and 1.0.
const TextAlignVertical({
required this.y,
}) : assert(y != null),
assert(y >= -1.0 && y <= 1.0);
}) : assert(y >= -1.0 && y <= 1.0);
/// A value ranging from -1.0 to 1.0 that defines the topmost and bottommost
/// locations of the top and bottom of the input box.
......
......@@ -136,7 +136,6 @@ enum Axis {
///
/// * [flipAxisDirection], which does the same thing for [AxisDirection] values.
Axis flipAxis(Axis direction) {
assert(direction != null);
switch (direction) {
case Axis.horizontal:
return Axis.vertical;
......@@ -204,7 +203,6 @@ enum AxisDirection {
/// [AxisDirection.down] and returns [Axis.horizontal] for [AxisDirection.left]
/// and [AxisDirection.right].
Axis axisDirectionToAxis(AxisDirection axisDirection) {
assert(axisDirection != null);
switch (axisDirection) {
case AxisDirection.up:
case AxisDirection.down:
......@@ -220,7 +218,6 @@ Axis axisDirectionToAxis(AxisDirection axisDirection) {
/// Specifically, returns [AxisDirection.left] for [TextDirection.rtl] and
/// [AxisDirection.right] for [TextDirection.ltr].
AxisDirection textDirectionToAxisDirection(TextDirection textDirection) {
assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
return AxisDirection.left;
......@@ -239,7 +236,6 @@ AxisDirection textDirectionToAxisDirection(TextDirection textDirection) {
///
/// * [flipAxis], which does the same thing for [Axis] values.
AxisDirection flipAxisDirection(AxisDirection axisDirection) {
assert(axisDirection != null);
switch (axisDirection) {
case AxisDirection.up:
return AxisDirection.down;
......@@ -258,7 +254,6 @@ AxisDirection flipAxisDirection(AxisDirection axisDirection) {
/// Specifically, returns true for [AxisDirection.up] and [AxisDirection.left]
/// and false for [AxisDirection.down] and [AxisDirection.right].
bool axisDirectionIsReversed(AxisDirection axisDirection) {
assert(axisDirection != null);
switch (axisDirection) {
case AxisDirection.up:
case AxisDirection.left:
......
......@@ -25,8 +25,7 @@ class BeveledRectangleBorder extends OutlinedBorder {
const BeveledRectangleBorder({
super.side,
this.borderRadius = BorderRadius.zero,
}) : assert(side != null),
assert(borderRadius != null);
});
/// The radii for each corner.
///
......@@ -49,7 +48,6 @@ class BeveledRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is BeveledRectangleBorder) {
return BeveledRectangleBorder(
side: BorderSide.lerp(a.side, side, t),
......@@ -61,7 +59,6 @@ class BeveledRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is BeveledRectangleBorder) {
return BeveledRectangleBorder(
side: BorderSide.lerp(side, b.side, t),
......
......@@ -111,7 +111,6 @@ mixin PaintingBinding on BindingBase, ServicesBinding {
}) {
assert(cacheWidth == null || cacheWidth > 0);
assert(cacheHeight == null || cacheHeight > 0);
assert(allowUpscaling != null);
return ui.instantiateImageCodec(
bytes,
targetWidth: cacheWidth,
......@@ -149,7 +148,6 @@ mixin PaintingBinding on BindingBase, ServicesBinding {
}) {
assert(cacheWidth == null || cacheWidth > 0);
assert(cacheHeight == null || cacheHeight > 0);
assert(allowUpscaling != null);
return ui.instantiateImageCodecFromBuffer(
buffer,
targetWidth: cacheWidth,
......
......@@ -129,7 +129,6 @@ abstract class BorderRadiusGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static BorderRadiusGeometry? lerp(BorderRadiusGeometry? a, BorderRadiusGeometry? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -507,7 +506,6 @@ class BorderRadius extends BorderRadiusGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static BorderRadius? lerp(BorderRadius? a, BorderRadius? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -729,7 +727,6 @@ class BorderRadiusDirectional extends BorderRadiusGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static BorderRadiusDirectional? lerp(BorderRadiusDirectional? a, BorderRadiusDirectional? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -66,11 +66,7 @@ class BorderSide with Diagnosticable {
this.width = 1.0,
this.style = BorderStyle.solid,
this.strokeAlign = strokeAlignInside,
}) : assert(color != null),
assert(width != null),
assert(width >= 0.0),
assert(style != null),
assert(strokeAlign != null);
}) : assert(width >= 0.0);
/// Creates a [BorderSide] that represents the addition of the two given
/// [BorderSide]s.
......@@ -84,8 +80,6 @@ class BorderSide with Diagnosticable {
///
/// The arguments must not be null.
static BorderSide merge(BorderSide a, BorderSide b) {
assert(a != null);
assert(b != null);
assert(canMerge(a, b));
final bool aIsNone = a.style == BorderStyle.none && a.width == 0.0;
final bool bIsNone = b.style == BorderStyle.none && b.width == 0.0;
......@@ -202,7 +196,6 @@ class BorderSide with Diagnosticable {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
BorderSide scale(double t) {
assert(t != null);
return BorderSide(
color: color,
width: math.max(0.0, width * t),
......@@ -239,8 +232,6 @@ class BorderSide with Diagnosticable {
///
/// The arguments must not be null.
static bool canMerge(BorderSide a, BorderSide b) {
assert(a != null);
assert(b != null);
if ((a.style == BorderStyle.none && a.width == 0.0) ||
(b.style == BorderStyle.none && b.width == 0.0)) {
return true;
......@@ -255,9 +246,6 @@ class BorderSide with Diagnosticable {
///
/// {@macro dart.ui.shadow.lerp}
static BorderSide lerp(BorderSide a, BorderSide b, double t) {
assert(a != null);
assert(b != null);
assert(t != null);
if (t == 0.0) {
return a;
}
......@@ -517,7 +505,6 @@ abstract class ShapeBorder {
///
/// {@macro dart.ui.shadow.lerp}
static ShapeBorder? lerp(ShapeBorder? a, ShapeBorder? b, double t) {
assert(t != null);
ShapeBorder? result;
if (b != null) {
result = b.lerpFrom(a, t);
......@@ -664,7 +651,7 @@ abstract class OutlinedBorder extends ShapeBorder {
/// const constructors so that they can be used in const expressions.
///
/// The value of [side] must not be null.
const OutlinedBorder({ this.side = BorderSide.none }) : assert(side != null);
const OutlinedBorder({ this.side = BorderSide.none });
@override
EdgeInsetsGeometry get dimensions => EdgeInsets.all(math.max(side.strokeInset, 0));
......@@ -707,7 +694,6 @@ abstract class OutlinedBorder extends ShapeBorder {
///
/// {@macro dart.ui.shadow.lerp}
static OutlinedBorder? lerp(OutlinedBorder? a, OutlinedBorder? b, double t) {
assert(t != null);
ShapeBorder? result;
if (b != null) {
result = b.lerpFrom(a, t);
......@@ -724,8 +710,7 @@ abstract class OutlinedBorder extends ShapeBorder {
/// The borders are listed from the outside to the inside.
class _CompoundBorder extends ShapeBorder {
_CompoundBorder(this.borders)
: assert(borders != null),
assert(borders.length >= 2),
: assert(borders.length >= 2),
assert(!borders.any((ShapeBorder border) => border is _CompoundBorder));
final List<ShapeBorder> borders;
......@@ -788,7 +773,6 @@ class _CompoundBorder extends ShapeBorder {
}
static _CompoundBorder lerp(ShapeBorder? a, ShapeBorder? b, double t) {
assert(t != null);
assert(a is _CompoundBorder || b is _CompoundBorder); // Not really necessary, but all call sites currently intend this.
final List<ShapeBorder?> aList = a is _CompoundBorder ? a.borders : <ShapeBorder?>[a];
final List<ShapeBorder?> bList = b is _CompoundBorder ? b.borders : <ShapeBorder?>[b];
......@@ -897,12 +881,6 @@ void paintBorder(
BorderSide bottom = BorderSide.none,
BorderSide left = BorderSide.none,
}) {
assert(canvas != null);
assert(rect != null);
assert(top != null);
assert(right != null);
assert(bottom != null);
assert(left != null);
// We draw the borders as filled shapes, unless the borders are hairline
// borders, in which case we use PaintingStyle.stroke, with the stroke width
......
......@@ -103,7 +103,6 @@ abstract class BoxBorder extends ShapeBorder {
///
/// {@macro dart.ui.shadow.lerp}
static BoxBorder? lerp(BoxBorder? a, BoxBorder? b, double t) {
assert(t != null);
if ((a is Border?) && (b is Border?)) {
return Border.lerp(a, b, t);
}
......@@ -322,17 +321,13 @@ class Border extends BoxBorder {
this.right = BorderSide.none,
this.bottom = BorderSide.none,
this.left = BorderSide.none,
}) : assert(top != null),
assert(right != null),
assert(bottom != null),
assert(left != null);
});
/// Creates a border whose sides are all the same.
///
/// The `side` argument must not be null.
const Border.fromBorderSide(BorderSide side)
: assert(side != null),
top = side,
: top = side,
right = side,
bottom = side,
left = side;
......@@ -346,9 +341,7 @@ class Border extends BoxBorder {
const Border.symmetric({
BorderSide vertical = BorderSide.none,
BorderSide horizontal = BorderSide.none,
}) : assert(vertical != null),
assert(horizontal != null),
left = vertical,
}) : left = vertical,
top = horizontal,
right = vertical,
bottom = horizontal;
......@@ -374,8 +367,6 @@ class Border extends BoxBorder {
///
/// The arguments must not be null.
static Border merge(Border a, Border b) {
assert(a != null);
assert(b != null);
assert(BorderSide.canMerge(a.top, b.top));
assert(BorderSide.canMerge(a.right, b.right));
assert(BorderSide.canMerge(a.bottom, b.bottom));
......@@ -478,7 +469,6 @@ class Border extends BoxBorder {
///
/// {@macro dart.ui.shadow.lerp}
static Border? lerp(Border? a, Border? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -650,10 +640,7 @@ class BorderDirectional extends BoxBorder {
this.start = BorderSide.none,
this.end = BorderSide.none,
this.bottom = BorderSide.none,
}) : assert(top != null),
assert(start != null),
assert(end != null),
assert(bottom != null);
});
/// Creates a [BorderDirectional] that represents the addition of the two
/// given [BorderDirectional]s.
......@@ -663,8 +650,6 @@ class BorderDirectional extends BoxBorder {
///
/// The arguments must not be null.
static BorderDirectional merge(BorderDirectional a, BorderDirectional b) {
assert(a != null);
assert(b != null);
assert(BorderSide.canMerge(a.top, b.top));
assert(BorderSide.canMerge(a.start, b.start));
assert(BorderSide.canMerge(a.end, b.end));
......@@ -826,7 +811,6 @@ class BorderDirectional extends BoxBorder {
///
/// {@macro dart.ui.shadow.lerp}
static BorderDirectional? lerp(BorderDirectional? a, BorderDirectional? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -93,8 +93,7 @@ class BoxDecoration extends Decoration {
this.gradient,
this.backgroundBlendMode,
this.shape = BoxShape.rectangle,
}) : assert(shape != null),
assert(
}) : assert(
backgroundBlendMode == null || color != null || gradient != null,
"backgroundBlendMode applies to BoxDecoration's background color or "
'gradient, but no color or gradient was provided.',
......@@ -289,7 +288,6 @@ class BoxDecoration extends Decoration {
/// and which use [BoxDecoration.lerp] when interpolating two
/// [BoxDecoration]s or a [BoxDecoration] to or from null.
static BoxDecoration? lerp(BoxDecoration? a, BoxDecoration? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -365,7 +363,6 @@ class BoxDecoration extends Decoration {
@override
bool hitTest(Size size, Offset position, { TextDirection? textDirection }) {
assert(shape != null);
assert((Offset.zero & size).contains(position));
switch (shape) {
case BoxShape.rectangle:
......@@ -391,15 +388,13 @@ class BoxDecoration extends Decoration {
/// An object that paints a [BoxDecoration] into a canvas.
class _BoxDecorationPainter extends BoxPainter {
_BoxDecorationPainter(this._decoration, super.onChanged)
: assert(_decoration != null);
_BoxDecorationPainter(this._decoration, super.onChanged);
final BoxDecoration _decoration;
Paint? _cachedBackgroundPaint;
Rect? _rectForCachedBackgroundPaint;
Paint _getBackgroundPaint(Rect rect, TextDirection? textDirection) {
assert(rect != null);
assert(_decoration.gradient != null || _rectForCachedBackgroundPaint == null);
if (_cachedBackgroundPaint == null ||
......@@ -489,7 +484,6 @@ class _BoxDecorationPainter extends BoxPainter {
/// Paint the box decoration into the given location on the given canvas.
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration != null);
assert(configuration.size != null);
final Rect rect = offset & configuration.size!;
final TextDirection? textDirection = configuration.textDirection;
......
......@@ -86,7 +86,6 @@ class BoxShadow extends ui.Shadow {
///
/// {@macro dart.ui.shadow.lerp}
static BoxShadow? lerp(BoxShadow? a, BoxShadow? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -111,7 +110,6 @@ class BoxShadow extends ui.Shadow {
///
/// {@macro dart.ui.shadow.lerp}
static List<BoxShadow>? lerpList(List<BoxShadow>? a, List<BoxShadow>? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -33,9 +33,7 @@ class CircleBorder extends OutlinedBorder {
///
/// The [side] argument must not be null.
const CircleBorder({ super.side, this.eccentricity = 0.0 })
: assert(side != null),
assert(eccentricity != null),
assert(eccentricity >= 0.0, 'The eccentricity argument $eccentricity is not greater than or equal to zero.'),
: assert(eccentricity >= 0.0, 'The eccentricity argument $eccentricity is not greater than or equal to zero.'),
assert(eccentricity <= 1.0, 'The eccentricity argument $eccentricity is not less than or equal to one.');
/// Defines the ratio (0.0-1.0) from which the border will deform
......
......@@ -10,7 +10,6 @@ abstract class ClipContext {
Canvas get canvas;
void _clipAndPaint(void Function(bool doAntiAlias) canvasClipCall, Clip clipBehavior, Rect bounds, VoidCallback painter) {
assert(canvasClipCall != null);
canvas.save();
switch (clipBehavior) {
case Clip.none:
......
......@@ -89,11 +89,7 @@ class HSVColor {
/// All the arguments must not be null and be in their respective ranges. See
/// the fields for each parameter for a description of their ranges.
const HSVColor.fromAHSV(this.alpha, this.hue, this.saturation, this.value)
: assert(alpha != null),
assert(hue != null),
assert(saturation != null),
assert(value != null),
assert(alpha >= 0.0),
: assert(alpha >= 0.0),
assert(alpha <= 1.0),
assert(hue >= 0.0),
assert(hue <= 360.0),
......@@ -198,7 +194,6 @@ class HSVColor {
///
/// Values outside of the valid range for each channel will be clamped.
static HSVColor? lerp(HSVColor? a, HSVColor? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -262,11 +257,7 @@ class HSLColor {
/// All the arguments must not be null and be in their respective ranges. See
/// the fields for each parameter for a description of their ranges.
const HSLColor.fromAHSL(this.alpha, this.hue, this.saturation, this.lightness)
: assert(alpha != null),
assert(hue != null),
assert(saturation != null),
assert(lightness != null),
assert(alpha >= 0.0),
: assert(alpha >= 0.0),
assert(alpha <= 1.0),
assert(hue >= 0.0),
assert(hue <= 360.0),
......@@ -386,7 +377,6 @@ class HSLColor {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static HSLColor? lerp(HSLColor? a, HSLColor? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -519,9 +509,7 @@ class ColorProperty extends DiagnosticsProperty<Color> {
super.defaultValue,
super.style,
super.level,
}) : assert(showName != null),
assert(style != null),
assert(level != null);
});
@override
Map<String, Object?> toJsonMap(DiagnosticsSerializationDelegate delegate) {
......
......@@ -37,8 +37,7 @@ class ContinuousRectangleBorder extends OutlinedBorder {
const ContinuousRectangleBorder({
super.side,
this.borderRadius = BorderRadius.zero,
}) : assert(side != null),
assert(borderRadius != null);
});
/// The radius for each corner.
///
......@@ -59,7 +58,6 @@ class ContinuousRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is ContinuousRectangleBorder) {
return ContinuousRectangleBorder(
side: BorderSide.lerp(a.side, side, t),
......@@ -71,7 +69,6 @@ class ContinuousRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is ContinuousRectangleBorder) {
return ContinuousRectangleBorder(
side: BorderSide.lerp(side, b.side, t),
......
......@@ -129,7 +129,6 @@ abstract class Decoration with Diagnosticable {
///
/// {@macro dart.ui.shadow.lerp}
static Decoration? lerp(Decoration? a, Decoration? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -57,11 +57,7 @@ class DecorationImage {
this.filterQuality = FilterQuality.low,
this.invertColors = false,
this.isAntiAlias = false,
}) : assert(image != null),
assert(alignment != null),
assert(repeat != null),
assert(matchTextDirection != null),
assert(scale != null);
});
/// The image to be painted into the decoration.
///
......@@ -181,7 +177,6 @@ class DecorationImage {
/// image needs to be repainted, e.g. because it is loading incrementally or
/// because it is animated.
DecorationImagePainter createPainter(VoidCallback onChanged) {
assert(onChanged != null);
return DecorationImagePainter._(this, onChanged);
}
......@@ -265,7 +260,7 @@ class DecorationImage {
/// This object should be disposed using the [dispose] method when it is no
/// longer needed.
class DecorationImagePainter {
DecorationImagePainter._(this._details, this._onChanged) : assert(_details != null);
DecorationImagePainter._(this._details, this._onChanged);
final DecorationImage _details;
final VoidCallback _onChanged;
......@@ -288,9 +283,6 @@ class DecorationImagePainter {
/// then the `onChanged` callback passed to [DecorationImage.createPainter]
/// will be called.
void paint(Canvas canvas, Rect rect, Path? clipPath, ImageConfiguration configuration) {
assert(canvas != null);
assert(rect != null);
assert(configuration != null);
bool flipHorizontally = false;
if (_details.matchTextDirection) {
......@@ -367,7 +359,6 @@ class DecorationImagePainter {
}
_image?.dispose();
_image = value;
assert(_onChanged != null);
if (!synchronousCall) {
_onChanged();
}
......@@ -500,12 +491,6 @@ void paintImage({
FilterQuality filterQuality = FilterQuality.low,
bool isAntiAlias = false,
}) {
assert(canvas != null);
assert(image != null);
assert(alignment != null);
assert(repeat != null);
assert(flipHorizontally != null);
assert(isAntiAlias != null);
assert(
image.debugGetOpenHandleStackTraces()?.isNotEmpty ?? true,
'Cannot paint an image that is disposed.\n'
......
......@@ -64,7 +64,6 @@ abstract class EdgeInsetsGeometry {
/// The total offset in the given direction.
double along(Axis axis) {
assert(axis != null);
switch (axis) {
case Axis.horizontal:
return horizontal;
......@@ -216,7 +215,6 @@ abstract class EdgeInsetsGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static EdgeInsetsGeometry? lerp(EdgeInsetsGeometry? a, EdgeInsetsGeometry? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -604,7 +602,6 @@ class EdgeInsets extends EdgeInsetsGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static EdgeInsets? lerp(EdgeInsets? a, EdgeInsets? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -871,7 +868,6 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry {
///
/// {@macro dart.ui.shadow.lerp}
static EdgeInsetsDirectional? lerp(EdgeInsetsDirectional? a, EdgeInsetsDirectional? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -44,10 +44,7 @@ class FlutterLogoDecoration extends Decoration {
this.textColor = const Color(0xFF757575),
this.style = FlutterLogoStyle.markOnly,
this.margin = EdgeInsets.zero,
}) : assert(textColor != null),
assert(style != null),
assert(margin != null),
_position = identical(style, FlutterLogoStyle.markOnly) ? 0.0 : identical(style, FlutterLogoStyle.horizontal) ? 1.0 : -1.0,
}) : _position = identical(style, FlutterLogoStyle.markOnly) ? 0.0 : identical(style, FlutterLogoStyle.horizontal) ? 1.0 : -1.0,
_opacity = 1.0;
const FlutterLogoDecoration._(this.textColor, this.style, this.margin, this._position, this._opacity);
......@@ -78,12 +75,7 @@ class FlutterLogoDecoration extends Decoration {
@override
bool debugAssertIsValid() {
assert(
textColor != null
&& style != null
&& margin != null
&& _position != null
&& _position.isFinite
&& _opacity != null
_position.isFinite
&& _opacity >= 0.0
&& _opacity <= 1.0,
);
......@@ -107,7 +99,6 @@ class FlutterLogoDecoration extends Decoration {
///
/// * [Decoration.lerp], which interpolates between arbitrary decorations.
static FlutterLogoDecoration? lerp(FlutterLogoDecoration? a, FlutterLogoDecoration? b, double t) {
assert(t != null);
assert(a == null || a.debugAssertIsValid());
assert(b == null || b.debugAssertIsValid());
if (a == null && b == null) {
......@@ -218,8 +209,7 @@ class FlutterLogoDecoration extends Decoration {
/// An object that paints a [BoxDecoration] into a canvas.
class _FlutterLogoPainter extends BoxPainter {
_FlutterLogoPainter(this._config)
: assert(_config != null),
assert(_config.debugAssertIsValid()),
: assert(_config.debugAssertIsValid()),
super(null) {
_prepareText();
}
......
......@@ -56,17 +56,13 @@ class FractionalOffset extends Alignment {
///
/// The [dx] and [dy] arguments must not be null.
const FractionalOffset(double dx, double dy)
: assert(dx != null),
assert(dy != null),
super(dx * 2.0 - 1.0, dy * 2.0 - 1.0);
: super(dx * 2.0 - 1.0, dy * 2.0 - 1.0);
/// Creates a fractional offset from a specific offset and size.
///
/// The returned [FractionalOffset] describes the position of the
/// [Offset] in the [Size], as a fraction of the [Size].
factory FractionalOffset.fromOffsetAndSize(Offset offset, Size size) {
assert(size != null);
assert(offset != null);
return FractionalOffset(
offset.dx / size.width,
offset.dy / size.height,
......@@ -180,7 +176,6 @@ class FractionalOffset extends Alignment {
///
/// {@macro dart.ui.shadow.lerp}
static FractionalOffset? lerp(FractionalOffset? a, FractionalOffset? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -45,12 +45,6 @@ Offset positionDependentBox({
double verticalOffset = 0.0,
double margin = 10.0,
}) {
assert(size != null);
assert(childSize != null);
assert(target != null);
assert(verticalOffset != null);
assert(preferBelow != null);
assert(margin != null);
// VERTICAL DIRECTION
final bool fitsBelow = target.dy + verticalOffset + childSize.height <= size.height - margin;
final bool fitsAbove = target.dy - verticalOffset - childSize.height >= margin;
......
......@@ -20,11 +20,8 @@ class _ColorsAndStops {
/// Calculate the color at position [t] of the gradient defined by [colors] and [stops].
Color _sample(List<Color> colors, List<double> stops, double t) {
assert(colors != null);
assert(colors.isNotEmpty);
assert(stops != null);
assert(stops.isNotEmpty);
assert(t != null);
if (t <= stops.first) {
return colors.first;
}
......@@ -107,7 +104,6 @@ class GradientRotation extends GradientTransform {
@override
Matrix4 transform(Rect bounds, {TextDirection? textDirection}) {
assert(bounds != null);
final double sinRadians = math.sin(radians);
final double oneMinusCosRadians = 1 - math.cos(radians);
final Offset center = bounds.center;
......@@ -170,7 +166,7 @@ abstract class Gradient {
required this.colors,
this.stops,
this.transform,
}) : assert(colors != null);
});
/// The colors the gradient should obtain at each of the stops.
///
......@@ -311,7 +307,6 @@ abstract class Gradient {
///
/// {@macro dart.ui.shadow.lerp}
static Gradient? lerp(Gradient? a, Gradient? b, double t) {
assert(t != null);
Gradient? result;
if (b != null) {
result = b.lerpFrom(a, t); // if a is null, this must return non-null
......@@ -388,9 +383,7 @@ class LinearGradient extends Gradient {
super.stops,
this.tileMode = TileMode.clamp,
super.transform,
}) : assert(begin != null),
assert(end != null),
assert(tileMode != null);
});
/// The offset at which stop 0.0 of the gradient is placed.
///
......@@ -493,7 +486,6 @@ class LinearGradient extends Gradient {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static LinearGradient? lerp(LinearGradient? a, LinearGradient? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -644,10 +636,7 @@ class RadialGradient extends Gradient {
this.focal,
this.focalRadius = 0.0,
super.transform,
}) : assert(center != null),
assert(radius != null),
assert(tileMode != null),
assert(focalRadius != null);
});
/// The center of the gradient, as an offset into the (-1.0, -1.0) x (1.0, 1.0)
/// square describing the gradient which will be mapped onto the paint box.
......@@ -776,7 +765,6 @@ class RadialGradient extends Gradient {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static RadialGradient? lerp(RadialGradient? a, RadialGradient? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -943,10 +931,7 @@ class SweepGradient extends Gradient {
super.stops,
this.tileMode = TileMode.clamp,
super.transform,
}) : assert(center != null),
assert(startAngle != null),
assert(endAngle != null),
assert(tileMode != null);
});
/// The center of the gradient, as an offset into the (-1.0, -1.0) x (1.0, 1.0)
/// square describing the gradient which will be mapped onto the paint box.
......@@ -1047,7 +1032,6 @@ class SweepGradient extends Gradient {
/// Values for `t` are usually obtained from an [Animation<double>], such as
/// an [AnimationController].
static SweepGradient? lerp(SweepGradient? a, SweepGradient? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......
......@@ -99,7 +99,6 @@ class ImageCache {
/// returning it to its original value will therefore immediately clear the
/// cache.
set maximumSize(int value) {
assert(value != null);
assert(value >= 0);
if (value == maximumSize) {
return;
......@@ -139,7 +138,6 @@ class ImageCache {
/// returning it to its original value will therefore immediately clear the
/// cache.
set maximumSizeBytes(int value) {
assert(value != null);
assert(value >= 0);
if (value == _maximumSizeBytes) {
return;
......@@ -240,7 +238,6 @@ class ImageCache {
///
/// * [ImageProvider], for providing images to the [Image] widget.
bool evict(Object key, { bool includeLive = true }) {
assert(includeLive != null);
if (includeLive) {
// Remove from live images - the cache will not be able to mark
// it as complete, and it might be getting evicted because it
......@@ -324,8 +321,6 @@ class ImageCache {
/// no completers are cached and `null` is returned instead of a new
/// completer.
ImageStreamCompleter? putIfAbsent(Object key, ImageStreamCompleter Function() loader, { ImageErrorListener? onError }) {
assert(key != null);
assert(loader != null);
TimelineTask? timelineTask;
TimelineTask? listenerTask;
if (!kReleaseMode) {
......@@ -613,8 +608,7 @@ abstract class _CachedImageBase {
_CachedImageBase(
this.completer, {
this.sizeBytes,
}) : assert(completer != null),
handle = completer.keepAlive();
}) : handle = completer.keepAlive();
final ImageStreamCompleter completer;
int? sizeBytes;
......
......@@ -348,7 +348,6 @@ abstract class ImageProvider<T extends Object> {
/// See the Lifecycle documentation on [ImageProvider] for more information.
@nonVirtual
ImageStream resolve(ImageConfiguration configuration) {
assert(configuration != null);
final ImageStream stream = createStream(configuration);
// Load the key (potentially asynchronously), set up an error handling zone,
// and call resolveStreamForKey.
......@@ -407,7 +406,6 @@ abstract class ImageProvider<T extends Object> {
required ImageConfiguration configuration,
ImageErrorListener? handleError,
}) {
assert(configuration != null);
final Completer<ImageCacheStatus?> completer = Completer<ImageCacheStatus?>();
_createErrorHandlerAndKey(
configuration,
......@@ -635,9 +633,7 @@ class AssetBundleImageKey {
required this.bundle,
required this.name,
required this.scale,
}) : assert(bundle != null),
assert(name != null),
assert(scale != null);
});
/// The bundle from which the image will be obtained.
///
......@@ -733,10 +729,6 @@ abstract class AssetBundleImageProvider extends ImageProvider<AssetBundleImageKe
PaintingBinding.instance.imageCache.evict(key);
rethrow;
}
if (buffer == null) {
PaintingBinding.instance.imageCache.evict(key);
throw StateError('Unable to read data');
}
return decode(buffer);
}
ByteData data;
......@@ -748,10 +740,6 @@ abstract class AssetBundleImageProvider extends ImageProvider<AssetBundleImageKe
PaintingBinding.instance.imageCache.evict(key);
rethrow;
}
if (data == null) {
PaintingBinding.instance.imageCache.evict(key);
throw StateError('Unable to read data');
}
return decodeDepreacted!(data.buffer.asUint8List());
}
}
......@@ -803,8 +791,7 @@ class ResizeImage extends ImageProvider<ResizeImageKey> {
this.width,
this.height,
this.allowUpscaling = false,
}) : assert(width != null || height != null),
assert(allowUpscaling != null);
}) : assert(width != null || height != null);
/// The [ImageProvider] that this class wraps.
final ImageProvider imageProvider;
......@@ -950,9 +937,7 @@ class FileImage extends ImageProvider<FileImage> {
/// Creates an object that decodes a [File] as an image.
///
/// The arguments must not be null.
const FileImage(this.file, { this.scale = 1.0 })
: assert(file != null),
assert(scale != null);
const FileImage(this.file, { this.scale = 1.0 });
/// The file to decode into an image.
final File file;
......@@ -1045,9 +1030,7 @@ class MemoryImage extends ImageProvider<MemoryImage> {
/// Creates an object that decodes a [Uint8List] buffer as an image.
///
/// The arguments must not be null.
const MemoryImage(this.bytes, { this.scale = 1.0 })
: assert(bytes != null),
assert(scale != null);
const MemoryImage(this.bytes, { this.scale = 1.0 });
/// The bytes to decode into an image.
///
......@@ -1204,8 +1187,7 @@ class ExactAssetImage extends AssetBundleImageProvider {
this.scale = 1.0,
this.bundle,
this.package,
}) : assert(assetName != null),
assert(scale != null);
});
/// The name of the asset.
final String assetName;
......@@ -1266,9 +1248,7 @@ class NetworkImageLoadException implements Exception {
/// Creates a [NetworkImageLoadException] with the specified http [statusCode]
/// and [uri].
NetworkImageLoadException({required this.statusCode, required this.uri})
: assert(uri != null),
assert(statusCode != null),
_message = 'HTTP request failed, statusCode: $statusCode, $uri';
: _message = 'HTTP request failed, statusCode: $statusCode, $uri';
/// The HTTP status code from the server.
final int statusCode;
......
......@@ -244,7 +244,7 @@ class AssetImage extends AssetBundleImageProvider {
this.assetName, {
this.bundle,
this.package,
}) : assert(assetName != null);
});
/// The name of the main asset from the set of images to choose from. See the
/// documentation for the [AssetImage] class itself for details.
......
......@@ -23,9 +23,7 @@ class ImageInfo {
/// Both the [image] and the [scale] must not be null.
///
/// The [debugLabel] may be used to identify the source of this image.
const ImageInfo({ required this.image, this.scale = 1.0, this.debugLabel })
: assert(image != null),
assert(scale != null);
const ImageInfo({ required this.image, this.scale = 1.0, this.debugLabel });
/// Creates an [ImageInfo] with a cloned [image].
///
......@@ -167,7 +165,7 @@ class ImageStreamListener {
this.onImage, {
this.onChunk,
this.onError,
}) : assert(onImage != null);
});
/// Callback for getting notified that an image is available.
///
......@@ -623,7 +621,6 @@ abstract class ImageStreamCompleter with Diagnosticable {
///
/// This callback will never fire if [removeListener] is never called.
void addOnLastListenerRemovedCallback(VoidCallback callback) {
assert(callback != null);
_checkDisposed();
_onLastListenerRemovedCallbacks.add(callback);
}
......@@ -631,7 +628,6 @@ abstract class ImageStreamCompleter with Diagnosticable {
/// Removes a callback previously supplied to
/// [addOnLastListenerRemovedCallback].
void removeOnLastListenerRemovedCallback(VoidCallback callback) {
assert(callback != null);
_checkDisposed();
_onLastListenerRemovedCallbacks.remove(callback);
}
......@@ -789,8 +785,7 @@ class OneFrameImageStreamCompleter extends ImageStreamCompleter {
/// argument on [FlutterErrorDetails] set to true, meaning that by default the
/// message is only dumped to the console in debug mode (see [
/// FlutterErrorDetails]).
OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector? informationCollector })
: assert(image != null) {
OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector? informationCollector }) {
image.then<void>(setImage, onError: (Object error, StackTrace stack) {
reportError(
context: ErrorDescription('resolving a single-frame image stream'),
......@@ -859,8 +854,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter {
String? debugLabel,
Stream<ImageChunkEvent>? chunkEvents,
InformationCollector? informationCollector,
}) : assert(codec != null),
_informationCollector = informationCollector,
}) : _informationCollector = informationCollector,
_scale = scale {
this.debugLabel = debugLabel;
codec.then<void>(_handleCodecReady, onError: (Object error, StackTrace stack) {
......
......@@ -60,9 +60,7 @@ class InlineSpanSemanticsInformation {
this.semanticsLabel,
this.stringAttributes = const <ui.StringAttribute>[],
this.recognizer,
}) : assert(text != null),
assert(isPlaceholder != null),
assert(isPlaceholder == false || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)),
}) : assert(isPlaceholder == false || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)),
requiresOwnNode = isPlaceholder || recognizer != null;
/// The text info for a [PlaceholderSpan].
......
......@@ -18,7 +18,6 @@ class MatrixUtils {
///
/// Otherwise, returns null.
static Offset? getAsTranslation(Matrix4 transform) {
assert(transform != null);
final Float64List values = transform.storage;
// Values are stored in column-major order.
if (values[0] == 1.0 && // col 1
......@@ -45,7 +44,6 @@ class MatrixUtils {
///
/// Otherwise, returns null.
static double? getAsScale(Matrix4 transform) {
assert(transform != null);
final Float64List values = transform.storage;
// Values are stored in column-major order.
if (values[1] == 0.0 && // col 1 (value 0 is the scale)
......@@ -81,7 +79,6 @@ class MatrixUtils {
if (b == null) {
return isIdentity(a);
}
assert(a != null && b != null);
return a.storage[0] == b.storage[0]
&& a.storage[1] == b.storage[1]
&& a.storage[2] == b.storage[2]
......@@ -102,7 +99,6 @@ class MatrixUtils {
/// Whether the given matrix is the identity matrix.
static bool isIdentity(Matrix4 a) {
assert(a != null);
return a.storage[0] == 1.0 // col 1
&& a.storage[1] == 0.0
&& a.storage[2] == 0.0
......@@ -437,7 +433,6 @@ class MatrixUtils {
/// The transformed rect is then projected back into the plane with z equals
/// 0.0 before computing its bounding rect.
static Rect inverseTransformRect(Matrix4 transform, Rect rect) {
assert(rect != null);
// As exposed by `unrelated_type_equality_checks`, this assert was a no-op.
// Fixing it introduces a bunch of runtime failures; for more context see:
// https://github.com/flutter/flutter/pull/31568
......@@ -487,10 +482,7 @@ class MatrixUtils {
double perspective = 0.001,
Axis orientation = Axis.vertical,
}) {
assert(radius != null);
assert(angle != null);
assert(perspective >= 0 && perspective <= 1.0);
assert(orientation != null);
// Pre-multiplied matrix of a projection matrix and a view matrix.
//
......@@ -561,8 +553,7 @@ class TransformProperty extends DiagnosticsProperty<Matrix4> {
super.showName,
super.defaultValue,
super.level,
}) : assert(showName != null),
assert(level != null);
});
@override
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
......
......@@ -30,8 +30,7 @@ class RoundedRectangleBorder extends OutlinedBorder {
const RoundedRectangleBorder({
super.side,
this.borderRadius = BorderRadius.zero,
}) : assert(side != null),
assert(borderRadius != null);
});
/// The radii for each corner.
final BorderRadiusGeometry borderRadius;
......@@ -46,7 +45,6 @@ class RoundedRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is RoundedRectangleBorder) {
return RoundedRectangleBorder(
side: BorderSide.lerp(a.side, side, t),
......@@ -66,7 +64,6 @@ class RoundedRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is RoundedRectangleBorder) {
return RoundedRectangleBorder(
side: BorderSide.lerp(side, b.side, t),
......@@ -165,9 +162,7 @@ class _RoundedRectangleToCircleBorder extends OutlinedBorder {
this.borderRadius = BorderRadius.zero,
required this.circularity,
required this.eccentricity,
}) : assert(side != null),
assert(borderRadius != null),
assert(circularity != null);
});
final BorderRadiusGeometry borderRadius;
final double circularity;
......@@ -185,7 +180,6 @@ class _RoundedRectangleToCircleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is RoundedRectangleBorder) {
return _RoundedRectangleToCircleBorder(
side: BorderSide.lerp(a.side, side, t),
......
......@@ -76,8 +76,7 @@ class ShapeDecoration extends Decoration {
this.gradient,
this.shadows,
required this.shape,
}) : assert(!(color != null && gradient != null)),
assert(shape != null);
}) : assert(!(color != null && gradient != null));
/// Creates a shape decoration configured to match a [BoxDecoration].
///
......@@ -91,7 +90,6 @@ class ShapeDecoration extends Decoration {
/// transition from a [BoxShape.circle] to [BoxShape.rectangle]).
factory ShapeDecoration.fromBoxDecoration(BoxDecoration source) {
final ShapeBorder shape;
assert(source.shape != null);
switch (source.shape) {
case BoxShape.circle:
if (source.border != null) {
......@@ -227,7 +225,6 @@ class ShapeDecoration extends Decoration {
/// and which use [ShapeDecoration.lerp] when interpolating two
/// [ShapeDecoration]s or a [ShapeDecoration] to or from null.
static ShapeDecoration? lerp(ShapeDecoration? a, ShapeDecoration? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -299,8 +296,7 @@ class ShapeDecoration extends Decoration {
/// An object that paints a [ShapeDecoration] into a canvas.
class _ShapeDecorationPainter extends BoxPainter {
_ShapeDecorationPainter(this._decoration, VoidCallback onChanged)
: assert(_decoration != null),
super(onChanged);
: super(onChanged);
final ShapeDecoration _decoration;
......@@ -318,7 +314,6 @@ class _ShapeDecorationPainter extends BoxPainter {
VoidCallback get onChanged => super.onChanged!;
void _precache(Rect rect, TextDirection? textDirection) {
assert(rect != null);
if (rect == _lastRect && textDirection == _lastTextDirection) {
return;
}
......@@ -409,7 +404,6 @@ class _ShapeDecorationPainter extends BoxPainter {
@override
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
assert(configuration != null);
assert(configuration.size != null);
final Rect rect = offset & configuration.size!;
final TextDirection? textDirection = configuration.textDirection;
......
......@@ -27,14 +27,13 @@ class StadiumBorder extends OutlinedBorder {
/// Create a stadium border.
///
/// The [side] argument must not be null.
const StadiumBorder({ super.side }) : assert(side != null);
const StadiumBorder({ super.side });
@override
ShapeBorder scale(double t) => StadiumBorder(side: side.scale(t));
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is StadiumBorder) {
return StadiumBorder(side: BorderSide.lerp(a.side, side, t));
}
......@@ -57,7 +56,6 @@ class StadiumBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is StadiumBorder) {
return StadiumBorder(side: BorderSide.lerp(side, b.side, t));
}
......@@ -144,8 +142,7 @@ class _StadiumToCircleBorder extends OutlinedBorder {
super.side,
this.circularity = 0.0,
required this.eccentricity,
}) : assert(side != null),
assert(circularity != null);
});
final double circularity;
final double eccentricity;
......@@ -161,7 +158,6 @@ class _StadiumToCircleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is StadiumBorder) {
return _StadiumToCircleBorder(
side: BorderSide.lerp(a.side, side, t),
......@@ -188,7 +184,6 @@ class _StadiumToCircleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is StadiumBorder) {
return _StadiumToCircleBorder(
side: BorderSide.lerp(side, b.side, t),
......@@ -326,9 +321,7 @@ class _StadiumToRoundedRectangleBorder extends OutlinedBorder {
super.side,
this.borderRadius = BorderRadius.zero,
this.rectilinearity = 0.0,
}) : assert(side != null),
assert(borderRadius != null),
assert(rectilinearity != null);
});
final BorderRadiusGeometry borderRadius;
......@@ -345,7 +338,6 @@ class _StadiumToRoundedRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpFrom(ShapeBorder? a, double t) {
assert(t != null);
if (a is StadiumBorder) {
return _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(a.side, side, t),
......@@ -372,7 +364,6 @@ class _StadiumToRoundedRectangleBorder extends OutlinedBorder {
@override
ShapeBorder? lerpTo(ShapeBorder? b, double t) {
assert(t != null);
if (b is StadiumBorder) {
return _StadiumToRoundedRectangleBorder(
side: BorderSide.lerp(side, b.side, t),
......
......@@ -468,8 +468,8 @@ class _StarGenerator {
required this.rotation,
required this.squash,
}) : assert(points > 1),
assert(innerRadiusRatio == null || innerRadiusRatio <= 1),
assert(innerRadiusRatio == null || innerRadiusRatio >= 0),
assert(innerRadiusRatio <= 1),
assert(innerRadiusRatio >= 0),
assert(squash >= 0),
assert(squash <= 1),
assert(pointRounding >= 0),
......@@ -484,7 +484,6 @@ class _StarGenerator {
final double valleyRounding;
final double rotation;
final double squash;
bool get isStar => innerRadiusRatio != null;
Path generate(Rect rect) {
final double radius = rect.shortestSide / 2;
......
......@@ -347,8 +347,7 @@ class StrutStyle with Diagnosticable {
this.forceStrutHeight,
String? debugLabel,
String? package,
}) : assert(textStyle != null),
assert(fontSize == null || fontSize > 0),
}) : assert(fontSize == null || fontSize > 0),
assert(leading == null || leading >= 0),
assert(package == null || fontFamily != null || fontFamilyFallback != null),
fontFamily = fontFamily != null ? (package == null ? fontFamily : 'packages/$package/$fontFamily') : textStyle.fontFamily,
......
......@@ -74,8 +74,7 @@ class PlaceholderDimensions {
required this.alignment,
this.baseline,
this.baselineOffset,
}) : assert(size != null),
assert(alignment != null);
});
/// A constant representing an empty placeholder.
static const PlaceholderDimensions empty = PlaceholderDimensions(size: Size.zero, alignment: ui.PlaceholderAlignment.bottom);
......@@ -329,10 +328,7 @@ class TextPainter {
TextWidthBasis textWidthBasis = TextWidthBasis.parent,
ui.TextHeightBehavior? textHeightBehavior,
}) : assert(text == null || text.debugAssertIsValid()),
assert(textAlign != null),
assert(textScaleFactor != null),
assert(maxLines == null || maxLines > 0),
assert(textWidthBasis != null),
_text = text,
_textAlign = textAlign,
_textDirection = textDirection,
......@@ -527,7 +523,6 @@ class TextPainter {
TextAlign get textAlign => _textAlign;
TextAlign _textAlign;
set textAlign(TextAlign value) {
assert(value != null);
if (_textAlign == value) {
return;
}
......@@ -571,7 +566,6 @@ class TextPainter {
double get textScaleFactor => _textScaleFactor;
double _textScaleFactor;
set textScaleFactor(double value) {
assert(value != null);
if (_textScaleFactor == value) {
return;
}
......@@ -666,7 +660,6 @@ class TextPainter {
TextWidthBasis get textWidthBasis => _textWidthBasis;
TextWidthBasis _textWidthBasis;
set textWidthBasis(TextWidthBasis value) {
assert(value != null);
if (_textWidthBasis == value) {
return;
}
......@@ -734,7 +727,6 @@ class TextPainter {
ui.ParagraphStyle _createParagraphStyle([ TextDirection? defaultTextDirection ]) {
// The defaultTextDirection argument is used for preferredLineHeight in case
// textDirection hasn't yet been set.
assert(textAlign != null);
assert(textDirection != null || defaultTextDirection != null, 'TextPainter.textDirection must be set to a non-null value before using the TextPainter.');
return _text!.style?.getParagraphStyle(
textAlign: textAlign,
......@@ -847,7 +839,6 @@ class TextPainter {
/// Valid only after [layout] has been called.
double computeDistanceToActualBaseline(TextBaseline baseline) {
assert(_debugAssertTextLayoutIsValid);
assert(baseline != null);
switch (baseline) {
case TextBaseline.alphabetic:
return _paragraph!.alphabeticBaseline;
......@@ -1134,7 +1125,6 @@ class TextPainter {
Offset get _emptyOffset {
assert(_debugAssertTextLayoutIsValid); // implies textDirection is non-null
assert(textAlign != null);
switch (textAlign) {
case TextAlign.left:
return Offset.zero;
......@@ -1199,7 +1189,6 @@ class TextPainter {
return;
}
final int offset = position.offset;
assert(position.affinity != null);
Rect? rect;
switch (position.affinity) {
case TextAffinity.upstream: {
......@@ -1244,8 +1233,6 @@ class TextPainter {
ui.BoxWidthStyle boxWidthStyle = ui.BoxWidthStyle.tight,
}) {
assert(_debugAssertTextLayoutIsValid);
assert(boxHeightStyle != null);
assert(boxWidthStyle != null);
return _paragraph!.getBoxesForRange(
selection.start,
selection.end,
......
......@@ -291,7 +291,6 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
}
if (children != null) {
for (final InlineSpan child in children!) {
assert(child != null);
child.build(
builder,
textScaleFactor: textScaleFactor,
......@@ -452,18 +451,6 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
assert(() {
if (children != null) {
for (final InlineSpan child in children!) {
if (child == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('TextSpan contains a null child.'),
ErrorDescription(
'A TextSpan object with a non-null child list should not have any nulls in its child list.',
),
toDiagnosticsNode(
name: 'The full text in question was',
style: DiagnosticsTreeStyle.errorProperty,
),
]);
}
assert(child.debugAssertIsValid());
}
}
......@@ -590,14 +577,7 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
return const <DiagnosticsNode>[];
}
return children!.map<DiagnosticsNode>((InlineSpan child) {
// `child` has a non-nullable return type, but might be null when running
// with weak checking, so we need to null check it anyway (and ignore the
// warning that the null-handling logic is dead code).
if (child != null) {
return child.toDiagnosticsNode();
} else {
return DiagnosticsNode.message('<null child>');
}
return child.toDiagnosticsNode();
}).toList();
}
}
......@@ -504,7 +504,6 @@ class TextStyle with Diagnosticable {
}) : fontFamily = package == null ? fontFamily : 'packages/$package/$fontFamily',
_fontFamilyFallback = fontFamilyFallback,
_package = package,
assert(inherit != null),
assert(color == null || foreground == null, _kColorForegroundWarning),
assert(backgroundColor == null || background == null, _kColorBackgroundWarning);
......@@ -961,21 +960,10 @@ class TextStyle with Diagnosticable {
String? package,
TextOverflow? overflow,
}) {
assert(fontSizeFactor != null);
assert(fontSizeDelta != null);
assert(fontSize != null || (fontSizeFactor == 1.0 && fontSizeDelta == 0.0));
assert(fontWeightDelta != null);
assert(fontWeight != null || fontWeightDelta == 0.0);
assert(letterSpacingFactor != null);
assert(letterSpacingDelta != null);
assert(letterSpacing != null || (letterSpacingFactor == 1.0 && letterSpacingDelta == 0.0));
assert(wordSpacingFactor != null);
assert(wordSpacingDelta != null);
assert(wordSpacing != null || (wordSpacingFactor == 1.0 && wordSpacingDelta == 0.0));
assert(heightFactor != null);
assert(heightDelta != null);
assert(decorationThicknessFactor != null);
assert(decorationThicknessDelta != null);
assert(decorationThickness != null || (decorationThicknessFactor == 1.0 && decorationThicknessDelta == 0.0));
String? modifiedDebugLabel;
......@@ -1106,7 +1094,6 @@ class TextStyle with Diagnosticable {
/// as if they have a [background] paint (creating a new [Paint] if necessary
/// based on the [backgroundColor] property).
static TextStyle? lerp(TextStyle? a, TextStyle? b, double t) {
assert(t != null);
if (a == null && b == null) {
return null;
}
......@@ -1332,7 +1319,6 @@ class TextStyle with Diagnosticable {
double? height,
StrutStyle? strutStyle,
}) {
assert(textScaleFactor != null);
assert(maxLines == null || maxLines > 0);
final ui.TextLeadingDistribution? leadingDistribution = this.leadingDistribution;
final ui.TextHeightBehavior? effectiveTextHeightBehavior = textHeightBehavior
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment