diff --git a/packages/flutter/lib/src/painting/_network_image_io.dart b/packages/flutter/lib/src/painting/_network_image_io.dart index aa5fc2681a..574188f65a 100644 --- a/packages/flutter/lib/src/painting/_network_image_io.dart +++ b/packages/flutter/lib/src/painting/_network_image_io.dart @@ -44,7 +44,7 @@ class NetworkImage extends image_provider.ImageProvider chunkEvents = StreamController(); return MultiFrameImageStreamCompleter( - codec: _loadAsync(key, chunkEvents, decode), + codec: _loadAsync(key as NetworkImage, chunkEvents, decode), chunkEvents: chunkEvents.stream, scale: key.scale, informationCollector: () { @@ -111,9 +111,9 @@ class NetworkImage extends image_provider.ImageProvider[ DiagnosticsProperty('Image provider', this), - DiagnosticsProperty('Image key', key), + DiagnosticsProperty('Image key', key as NetworkImage), ]; }, ); @@ -55,13 +55,13 @@ class NetworkImage extends image_provider.ImageProvider _loadAsync(NetworkImage key, image_provider.DecoderCallback decode) async { + Future _loadAsync(NetworkImage key, image_provider.DecoderCallback decode) { assert(key == this); final Uri resolved = Uri.base.resolve(key.url); // This API only exists in the web engine implementation and is not // contained in the analyzer summary for Flutter. - return ui.webOnlyInstantiateImageCodecFromUrl(resolved); // ignore: undefined_function + return ui.webOnlyInstantiateImageCodecFromUrl(resolved) as Future; // ignore: undefined_function } @override @@ -69,8 +69,9 @@ class NetworkImage extends image_provider.ImageProvider handleSystemMessage(Object systemMessage) async { await super.handleSystemMessage(systemMessage); - final Map message = systemMessage; - final String type = message['type']; + final Map message = systemMessage as Map; + final String type = message['type'] as String; switch (type) { case 'fontsChange': _systemFonts.notifyListeners(); diff --git a/packages/flutter/lib/src/painting/border_radius.dart b/packages/flutter/lib/src/painting/border_radius.dart index 816d094796..f6a2c8af50 100644 --- a/packages/flutter/lib/src/painting/border_radius.dart +++ b/packages/flutter/lib/src/painting/border_radius.dart @@ -244,15 +244,15 @@ abstract class BorderRadiusGeometry { return true; if (runtimeType != other.runtimeType) return false; - final BorderRadiusGeometry typedOther = other; - return _topLeft == typedOther._topLeft - && _topRight == typedOther._topRight - && _bottomLeft == typedOther._bottomLeft - && _bottomRight == typedOther._bottomRight - && _topStart == typedOther._topStart - && _topEnd == typedOther._topEnd - && _bottomStart == typedOther._bottomStart - && _bottomEnd == typedOther._bottomEnd; + return other is BorderRadiusGeometry + && other._topLeft == _topLeft + && other._topRight == _topRight + && other._bottomLeft == _bottomLeft + && other._bottomRight == _bottomRight + && other._topStart == _topStart + && other._topEnd == _topEnd + && other._bottomStart == _bottomStart + && other._bottomEnd == _bottomEnd; } @override diff --git a/packages/flutter/lib/src/painting/borders.dart b/packages/flutter/lib/src/painting/borders.dart index 36322235a9..5725e3e381 100644 --- a/packages/flutter/lib/src/painting/borders.dart +++ b/packages/flutter/lib/src/painting/borders.dart @@ -257,10 +257,10 @@ class BorderSide { return true; if (runtimeType != other.runtimeType) return false; - final BorderSide typedOther = other; - return color == typedOther.color && - width == typedOther.width && - style == typedOther.style; + return other is BorderSide + && other.color == color + && other.width == width + && other.style == style; } @override @@ -615,16 +615,8 @@ class _CompoundBorder extends ShapeBorder { return true; if (runtimeType != other.runtimeType) return false; - final _CompoundBorder typedOther = other; - if (borders == typedOther.borders) - return true; - if (borders.length != typedOther.borders.length) - return false; - for (int index = 0; index < borders.length; index += 1) { - if (borders[index] != typedOther.borders[index]) - return false; - } - return true; + return other is _CompoundBorder + && listEquals(other.borders, borders); } @override diff --git a/packages/flutter/lib/src/painting/box_border.dart b/packages/flutter/lib/src/painting/box_border.dart index b6c7ce15a7..75fcbb31f6 100644 --- a/packages/flutter/lib/src/painting/box_border.dart +++ b/packages/flutter/lib/src/painting/box_border.dart @@ -105,9 +105,9 @@ abstract class BoxBorder extends ShapeBorder { static BoxBorder lerp(BoxBorder a, BoxBorder b, double t) { assert(t != null); if ((a is Border || a == null) && (b is Border || b == null)) - return Border.lerp(a, b, t); + return Border.lerp(a as Border, b as Border, t); if ((a is BorderDirectional || a == null) && (b is BorderDirectional || b == null)) - return BorderDirectional.lerp(a, b, t); + return BorderDirectional.lerp(a as BorderDirectional, b as BorderDirectional, t); if (b is Border && a is BorderDirectional) { final BoxBorder c = b; b = a; @@ -402,14 +402,12 @@ class Border extends BoxBorder { @override Border add(ShapeBorder other, { bool reversed = false }) { - if (other is! Border) - return null; - final Border typedOther = other; - if (BorderSide.canMerge(top, typedOther.top) && - BorderSide.canMerge(right, typedOther.right) && - BorderSide.canMerge(bottom, typedOther.bottom) && - BorderSide.canMerge(left, typedOther.left)) { - return Border.merge(this, typedOther); + if (other is Border && + BorderSide.canMerge(top, other.top) && + BorderSide.canMerge(right, other.right) && + BorderSide.canMerge(bottom, other.bottom) && + BorderSide.canMerge(left, other.left)) { + return Border.merge(this, other); } return null; } @@ -521,11 +519,11 @@ class Border extends BoxBorder { return true; if (runtimeType != other.runtimeType) return false; - final Border typedOther = other; - return top == typedOther.top && - right == typedOther.right && - bottom == typedOther.bottom && - left == typedOther.left; + return other is Border + && other.top == top + && other.right == right + && other.bottom == bottom + && other.left == left; } @override @@ -825,11 +823,11 @@ class BorderDirectional extends BoxBorder { return true; if (runtimeType != other.runtimeType) return false; - final BorderDirectional typedOther = other; - return top == typedOther.top && - start == typedOther.start && - end == typedOther.end && - bottom == typedOther.bottom; + return other is BorderDirectional + && other.top == top + && other.start == start + && other.end == end + && other.bottom == bottom; } @override diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index 9bf5851580..bb3b7b4353 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -250,7 +250,7 @@ class BoxDecoration extends Decoration { return scale(t); if (a is BoxDecoration) return BoxDecoration.lerp(a, this, t); - return super.lerpFrom(a, t); + return super.lerpFrom(a, t) as BoxDecoration; } @override @@ -259,7 +259,7 @@ class BoxDecoration extends Decoration { return scale(1.0 - t); if (b is BoxDecoration) return BoxDecoration.lerp(this, b, t); - return super.lerpTo(b, t); + return super.lerpTo(b, t) as BoxDecoration; } /// Linearly interpolate between two box decorations. @@ -314,14 +314,14 @@ class BoxDecoration extends Decoration { return true; if (runtimeType != other.runtimeType) return false; - final BoxDecoration typedOther = other; - return color == typedOther.color && - image == typedOther.image && - border == typedOther.border && - borderRadius == typedOther.borderRadius && - boxShadow == typedOther.boxShadow && - gradient == typedOther.gradient && - shape == typedOther.shape; + return other is BoxDecoration + && other.color == color + && other.image == image + && other.border == border + && other.borderRadius == borderRadius + && other.boxShadow == boxShadow + && other.gradient == gradient + && other.shape == shape; } @override @@ -483,7 +483,7 @@ class _BoxDecorationPainter extends BoxPainter { canvas, rect, shape: _decoration.shape, - borderRadius: _decoration.borderRadius, + borderRadius: _decoration.borderRadius as BorderRadius, textDirection: configuration.textDirection, ); } diff --git a/packages/flutter/lib/src/painting/box_shadow.dart b/packages/flutter/lib/src/painting/box_shadow.dart index 560d68c65a..e3d3ea3d8b 100644 --- a/packages/flutter/lib/src/painting/box_shadow.dart +++ b/packages/flutter/lib/src/painting/box_shadow.dart @@ -118,11 +118,11 @@ class BoxShadow extends ui.Shadow { return true; if (runtimeType != other.runtimeType) return false; - final BoxShadow typedOther = other; - return color == typedOther.color && - offset == typedOther.offset && - blurRadius == typedOther.blurRadius && - spreadRadius == typedOther.spreadRadius; + return other is BoxShadow + && other.color == color + && other.offset == offset + && other.blurRadius == blurRadius + && other.spreadRadius == spreadRadius; } @override diff --git a/packages/flutter/lib/src/painting/circle_border.dart b/packages/flutter/lib/src/painting/circle_border.dart index aaebb47dde..1ecefbfdb1 100644 --- a/packages/flutter/lib/src/painting/circle_border.dart +++ b/packages/flutter/lib/src/painting/circle_border.dart @@ -84,8 +84,8 @@ class CircleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final CircleBorder typedOther = other; - return side == typedOther.side; + return other is CircleBorder + && other.side == side; } @override diff --git a/packages/flutter/lib/src/painting/colors.dart b/packages/flutter/lib/src/painting/colors.dart index 877ad5a8a8..98fea46e41 100644 --- a/packages/flutter/lib/src/painting/colors.dart +++ b/packages/flutter/lib/src/painting/colors.dart @@ -206,10 +206,10 @@ class HSVColor { if (b == null) return a._scaleAlpha(1.0 - t); return HSVColor.fromAHSV( - lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0), + lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0) as double, lerpDouble(a.hue, b.hue, t) % 360.0, - lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0), - lerpDouble(a.value, b.value, t).clamp(0.0, 1.0), + lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0) as double, + lerpDouble(a.value, b.value, t).clamp(0.0, 1.0) as double, ); } @@ -217,13 +217,11 @@ class HSVColor { bool operator ==(dynamic other) { if (identical(this, other)) return true; - if (other is! HSVColor) - return false; - final HSVColor typedOther = other; - return typedOther.alpha == alpha - && typedOther.hue == hue - && typedOther.saturation == saturation - && typedOther.value == value; + return other is HSVColor + && other.alpha == alpha + && other.hue == hue + && other.saturation == saturation + && other.value == value; } @override @@ -292,7 +290,7 @@ class HSLColor { // Saturation can exceed 1.0 with rounding errors, so clamp it. final double saturation = lightness == 1.0 ? 0.0 - : (delta / (1.0 - (2.0 * lightness - 1.0).abs())).clamp(0.0, 1.0); + : ((delta / (1.0 - (2.0 * lightness - 1.0).abs())).clamp(0.0, 1.0) as double); return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } @@ -392,10 +390,10 @@ class HSLColor { if (b == null) return a._scaleAlpha(1.0 - t); return HSLColor.fromAHSL( - lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0), + lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0) as double, lerpDouble(a.hue, b.hue, t) % 360.0, - lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0), - lerpDouble(a.lightness, b.lightness, t).clamp(0.0, 1.0), + lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0) as double, + lerpDouble(a.lightness, b.lightness, t).clamp(0.0, 1.0) as double, ); } @@ -403,13 +401,11 @@ class HSLColor { bool operator ==(dynamic other) { if (identical(this, other)) return true; - if (other is! HSLColor) - return false; - final HSLColor typedOther = other; - return typedOther.alpha == alpha - && typedOther.hue == hue - && typedOther.saturation == saturation - && typedOther.lightness == lightness; + return other is HSLColor + && other.alpha == alpha + && other.hue == hue + && other.saturation == saturation + && other.lightness == lightness; } @override @@ -450,8 +446,9 @@ class ColorSwatch extends Color { return true; if (other.runtimeType != runtimeType) return false; - final ColorSwatch typedOther = other; - return super == other && _swatch == typedOther._swatch; + return super == other + && other is ColorSwatch + && other._swatch == _swatch; } @override diff --git a/packages/flutter/lib/src/painting/continuous_rectangle_border.dart b/packages/flutter/lib/src/painting/continuous_rectangle_border.dart index d53cfedb24..d10b280a2c 100644 --- a/packages/flutter/lib/src/painting/continuous_rectangle_border.dart +++ b/packages/flutter/lib/src/painting/continuous_rectangle_border.dart @@ -151,9 +151,9 @@ class ContinuousRectangleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final ContinuousRectangleBorder typedOther = other; - return side == typedOther.side - && borderRadius == typedOther.borderRadius; + return other is ContinuousRectangleBorder + && other.side == side + && other.borderRadius == borderRadius; } @override diff --git a/packages/flutter/lib/src/painting/decoration_image.dart b/packages/flutter/lib/src/painting/decoration_image.dart index db2d6abd41..fff0f06223 100644 --- a/packages/flutter/lib/src/painting/decoration_image.dart +++ b/packages/flutter/lib/src/painting/decoration_image.dart @@ -141,14 +141,14 @@ class DecorationImage { return true; if (runtimeType != other.runtimeType) return false; - final DecorationImage typedOther = other; - return image == typedOther.image - && colorFilter == typedOther.colorFilter - && fit == typedOther.fit - && alignment == typedOther.alignment - && centerSlice == typedOther.centerSlice - && repeat == typedOther.repeat - && matchTextDirection == typedOther.matchTextDirection; + return other is DecorationImage + && other.image == image + && other.colorFilter == colorFilter + && other.fit == fit + && other.alignment == alignment + && other.centerSlice == centerSlice + && other.repeat == repeat + && other.matchTextDirection == matchTextDirection; } @override @@ -392,8 +392,8 @@ void paintImage({ centerSlice.left + inputSize.width - centerSlice.right, centerSlice.top + inputSize.height - centerSlice.bottom, ); - outputSize -= sliceBorder; - inputSize -= sliceBorder; + outputSize = outputSize - sliceBorder as Size; + inputSize = inputSize - sliceBorder as Size; } fit ??= centerSlice == null ? BoxFit.scaleDown : BoxFit.fill; assert(centerSlice == null || (fit != BoxFit.none && fit != BoxFit.cover)); diff --git a/packages/flutter/lib/src/painting/edge_insets.dart b/packages/flutter/lib/src/painting/edge_insets.dart index acf5b346cd..4c2b61a059 100644 --- a/packages/flutter/lib/src/painting/edge_insets.dart +++ b/packages/flutter/lib/src/painting/edge_insets.dart @@ -280,15 +280,13 @@ abstract class EdgeInsetsGeometry { @override bool operator ==(dynamic other) { - if (other is! EdgeInsetsGeometry) - return false; - final EdgeInsetsGeometry typedOther = other; - return _left == typedOther._left - && _right == typedOther._right - && _start == typedOther._start - && _end == typedOther._end - && _top == typedOther._top - && _bottom == typedOther._bottom; + return other is EdgeInsetsGeometry + && other._left == _left + && other._right == _right + && other._start == _start + && other._end == _end + && other._top == _top + && other._bottom == _bottom; } @override diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 453b5a3d72..59b9da4824 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -171,7 +171,7 @@ class FlutterLogoDecoration extends Decoration { t < 0.5 ? a.style : b.style, EdgeInsets.lerp(a.margin, b.margin, t), a._position + (b._position - a._position) * t, - (a._opacity + (b._opacity - a._opacity) * t).clamp(0.0, 1.0), + (a._opacity + (b._opacity - a._opacity) * t).clamp(0.0, 1.0) as double, ); } @@ -180,9 +180,9 @@ class FlutterLogoDecoration extends Decoration { assert(debugAssertIsValid()); if (a == null || a is FlutterLogoDecoration) { assert(a == null || a.debugAssertIsValid()); - return FlutterLogoDecoration.lerp(a, this, t); + return FlutterLogoDecoration.lerp(a as FlutterLogoDecoration, this, t); } - return super.lerpFrom(a, t); + return super.lerpFrom(a, t) as FlutterLogoDecoration; } @override @@ -190,9 +190,9 @@ class FlutterLogoDecoration extends Decoration { assert(debugAssertIsValid()); if (b == null || b is FlutterLogoDecoration) { assert(b == null || b.debugAssertIsValid()); - return FlutterLogoDecoration.lerp(this, b, t); + return FlutterLogoDecoration.lerp(this, b as FlutterLogoDecoration, t); } - return super.lerpTo(b, t); + return super.lerpTo(b, t) as FlutterLogoDecoration; } @override @@ -210,14 +210,12 @@ class FlutterLogoDecoration extends Decoration { assert(debugAssertIsValid()); if (identical(this, other)) return true; - if (other is! FlutterLogoDecoration) - return false; - final FlutterLogoDecoration typedOther = other; - return lightColor == typedOther.lightColor - && darkColor == typedOther.darkColor - && textColor == typedOther.textColor - && _position == typedOther._position - && _opacity == typedOther._opacity; + return other is FlutterLogoDecoration + && other.lightColor == lightColor + && other.darkColor == darkColor + && other.textColor == textColor + && other._position == _position + && other._opacity == _opacity; } @override diff --git a/packages/flutter/lib/src/painting/fractional_offset.dart b/packages/flutter/lib/src/painting/fractional_offset.dart index f9d249d16b..ef4436187e 100644 --- a/packages/flutter/lib/src/painting/fractional_offset.dart +++ b/packages/flutter/lib/src/painting/fractional_offset.dart @@ -137,7 +137,7 @@ class FractionalOffset extends Alignment { Alignment operator -(Alignment other) { if (other is! FractionalOffset) return super - other; - final FractionalOffset typedOther = other; + final FractionalOffset typedOther = other as FractionalOffset; return FractionalOffset(dx - typedOther.dx, dy - typedOther.dy); } @@ -145,7 +145,7 @@ class FractionalOffset extends Alignment { Alignment operator +(Alignment other) { if (other is! FractionalOffset) return super + other; - final FractionalOffset typedOther = other; + final FractionalOffset typedOther = other as FractionalOffset; return FractionalOffset(dx + typedOther.dx, dy + typedOther.dy); } diff --git a/packages/flutter/lib/src/painting/geometry.dart b/packages/flutter/lib/src/painting/geometry.dart index ec3b9d4c0c..2b1d665e4b 100644 --- a/packages/flutter/lib/src/painting/geometry.dart +++ b/packages/flutter/lib/src/painting/geometry.dart @@ -66,7 +66,7 @@ Offset positionDependentBox({ if (size.width - margin * 2.0 < childSize.width) { x = (size.width - childSize.width) / 2.0; } else { - final double normalizedTargetX = target.dx.clamp(margin, size.width - margin); + final double normalizedTargetX = target.dx.clamp(margin, size.width - margin) as double; final double edge = margin + childSize.width / 2.0; if (normalizedTargetX < edge) { x = margin; diff --git a/packages/flutter/lib/src/painting/gradient.dart b/packages/flutter/lib/src/painting/gradient.dart index bcdd83e39f..3ff92e05f7 100644 --- a/packages/flutter/lib/src/painting/gradient.dart +++ b/packages/flutter/lib/src/painting/gradient.dart @@ -438,14 +438,14 @@ class LinearGradient extends Gradient { @override Gradient lerpFrom(Gradient a, double t) { if (a == null || (a is LinearGradient)) - return LinearGradient.lerp(a, this, t); + return LinearGradient.lerp(a as LinearGradient, this, t); return super.lerpFrom(a, t); } @override Gradient lerpTo(Gradient b, double t) { if (b == null || (b is LinearGradient)) - return LinearGradient.lerp(this, b, t); + return LinearGradient.lerp(this, b as LinearGradient, t); return super.lerpTo(b, t); } @@ -498,30 +498,12 @@ class LinearGradient extends Gradient { return true; if (runtimeType != other.runtimeType) return false; - final LinearGradient typedOther = other; - if (begin != typedOther.begin || - end != typedOther.end || - tileMode != typedOther.tileMode || - colors?.length != typedOther.colors?.length || - stops?.length != typedOther.stops?.length) - return false; - if (colors != null) { - assert(typedOther.colors != null); - assert(colors.length == typedOther.colors.length); - for (int i = 0; i < colors.length; i += 1) { - if (colors[i] != typedOther.colors[i]) - return false; - } - } - if (stops != null) { - assert(typedOther.stops != null); - assert(stops.length == typedOther.stops.length); - for (int i = 0; i < stops.length; i += 1) { - if (stops[i] != typedOther.stops[i]) - return false; - } - } - return true; + return other is LinearGradient + && other.begin == begin + && other.end == end + && other.tileMode == tileMode + && listEquals(other.colors, colors) + && listEquals(other.stops, stops); } @override @@ -714,14 +696,14 @@ class RadialGradient extends Gradient { @override Gradient lerpFrom(Gradient a, double t) { if (a == null || (a is RadialGradient)) - return RadialGradient.lerp(a, this, t); + return RadialGradient.lerp(a as RadialGradient, this, t); return super.lerpFrom(a, t); } @override Gradient lerpTo(Gradient b, double t) { if (b == null || (b is RadialGradient)) - return RadialGradient.lerp(this, b, t); + return RadialGradient.lerp(this, b as RadialGradient, t); return super.lerpTo(b, t); } @@ -776,32 +758,14 @@ class RadialGradient extends Gradient { return true; if (runtimeType != other.runtimeType) return false; - final RadialGradient typedOther = other; - if (center != typedOther.center || - radius != typedOther.radius || - tileMode != typedOther.tileMode || - colors?.length != typedOther.colors?.length || - stops?.length != typedOther.stops?.length || - focal != typedOther.focal || - focalRadius != typedOther.focalRadius) - return false; - if (colors != null) { - assert(typedOther.colors != null); - assert(colors.length == typedOther.colors.length); - for (int i = 0; i < colors.length; i += 1) { - if (colors[i] != typedOther.colors[i]) - return false; - } - } - if (stops != null) { - assert(typedOther.stops != null); - assert(stops.length == typedOther.stops.length); - for (int i = 0; i < stops.length; i += 1) { - if (stops[i] != typedOther.stops[i]) - return false; - } - } - return true; + return other is RadialGradient + && other.center == center + && other.radius == radius + && other.tileMode == tileMode + && listEquals(other.colors, colors) + && listEquals(other.stops, stops) + && other.focal == focal + && other.focalRadius == focalRadius; } @override @@ -980,14 +944,14 @@ class SweepGradient extends Gradient { @override Gradient lerpFrom(Gradient a, double t) { if (a == null || (a is SweepGradient)) - return SweepGradient.lerp(a, this, t); + return SweepGradient.lerp(a as SweepGradient, this, t); return super.lerpFrom(a, t); } @override Gradient lerpTo(Gradient b, double t) { if (b == null || (b is SweepGradient)) - return SweepGradient.lerp(this, b, t); + return SweepGradient.lerp(this, b as SweepGradient, t); return super.lerpTo(b, t); } @@ -1040,31 +1004,13 @@ class SweepGradient extends Gradient { return true; if (runtimeType != other.runtimeType) return false; - final SweepGradient typedOther = other; - if (center != typedOther.center || - startAngle != typedOther.startAngle || - endAngle != typedOther.endAngle || - tileMode != typedOther.tileMode || - colors?.length != typedOther.colors?.length || - stops?.length != typedOther.stops?.length) - return false; - if (colors != null) { - assert(typedOther.colors != null); - assert(colors.length == typedOther.colors.length); - for (int i = 0; i < colors.length; i += 1) { - if (colors[i] != typedOther.colors[i]) - return false; - } - } - if (stops != null) { - assert(typedOther.stops != null); - assert(stops.length == typedOther.stops.length); - for (int i = 0; i < stops.length; i += 1) { - if (stops[i] != typedOther.stops[i]) - return false; - } - } - return true; + return other is SweepGradient + && other.center == center + && other.startAngle == startAngle + && other.endAngle == endAngle + && other.tileMode == tileMode + && listEquals(other.colors, colors) + && listEquals(other.stops, stops); } @override diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index cc075db566..34205070b1 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -51,7 +51,7 @@ class ImageConfiguration { Locale locale, TextDirection textDirection, Size size, - String platform, + TargetPlatform platform, }) { return ImageConfiguration( bundle: bundle ?? this.bundle, @@ -94,13 +94,13 @@ class ImageConfiguration { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final ImageConfiguration typedOther = other; - return typedOther.bundle == bundle - && typedOther.devicePixelRatio == devicePixelRatio - && typedOther.locale == locale - && typedOther.textDirection == textDirection - && typedOther.size == size - && typedOther.platform == platform; + return other is ImageConfiguration + && other.bundle == bundle + && other.devicePixelRatio == devicePixelRatio + && other.locale == locale + && other.textDirection == textDirection + && other.size == size + && other.platform == platform; } @override @@ -439,10 +439,10 @@ class AssetBundleImageKey { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final AssetBundleImageKey typedOther = other; - return bundle == typedOther.bundle - && name == typedOther.name - && scale == typedOther.scale; + return other is AssetBundleImageKey + && other.bundle == bundle + && other.name == name + && other.scale == scale; } @override @@ -501,10 +501,10 @@ class _SizeAwareCacheKey { bool operator ==(Object other) { if (other.runtimeType != runtimeType) return false; - final _SizeAwareCacheKey typedOther = other; - return providerCacheKey == typedOther.providerCacheKey - && width == typedOther.width - && height == typedOther.height; + return other is _SizeAwareCacheKey + && other.providerCacheKey == providerCacheKey + && other.width == width + && other.height == height; } @override @@ -657,9 +657,9 @@ class FileImage extends ImageProvider { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final FileImage typedOther = other; - return file?.path == typedOther.file?.path - && scale == typedOther.scale; + return other is FileImage + && other.file?.path == file?.path + && other.scale == scale; } @override @@ -718,9 +718,9 @@ class MemoryImage extends ImageProvider { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final MemoryImage typedOther = other; - return bytes == typedOther.bytes - && scale == typedOther.scale; + return other is MemoryImage + && other.bytes == bytes + && other.scale == scale; } @override @@ -855,10 +855,10 @@ class ExactAssetImage extends AssetBundleImageProvider { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final ExactAssetImage typedOther = other; - return keyName == typedOther.keyName - && scale == typedOther.scale - && bundle == typedOther.bundle; + return other is ExactAssetImage + && other.keyName == keyName + && other.scale == scale + && other.bundle == bundle; } @override diff --git a/packages/flutter/lib/src/painting/image_resolution.dart b/packages/flutter/lib/src/painting/image_resolution.dart index bea456e712..fcc0bd7179 100644 --- a/packages/flutter/lib/src/painting/image_resolution.dart +++ b/packages/flutter/lib/src/painting/image_resolution.dart @@ -219,11 +219,11 @@ class AssetImage extends AssetBundleImageProvider { if (jsonData == null) return SynchronousFuture>>(null); // TODO(ianh): JSON decoding really shouldn't be on the main thread. - final Map parsedJson = json.decode(jsonData); + final Map parsedJson = json.decode(jsonData) as Map; final Iterable keys = parsedJson.keys; final Map> parsedManifest = Map>.fromIterables(keys, - keys.map>((String key) => List.from(parsedJson[key]))); + keys.map>((String key) => List.from(parsedJson[key] as List))); // TODO(ianh): convert that data structure to the right types. return SynchronousFuture>>(parsedManifest); } @@ -280,9 +280,9 @@ class AssetImage extends AssetBundleImageProvider { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final AssetImage typedOther = other; - return keyName == typedOther.keyName - && bundle == typedOther.bundle; + return other is AssetImage + && other.keyName == keyName + && other.bundle == bundle; } @override diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index 0f034ddf28..82e62a773d 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -50,9 +50,9 @@ class ImageInfo { bool operator ==(Object other) { if (other.runtimeType != runtimeType) return false; - final ImageInfo typedOther = other; - return typedOther.image == image - && typedOther.scale == scale; + return other is ImageInfo + && other.image == image + && other.scale == scale; } } @@ -119,10 +119,10 @@ class ImageStreamListener { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final ImageStreamListener typedOther = other; - return onImage == typedOther.onImage - && onChunk == typedOther.onChunk - && onError == typedOther.onError; + return other is ImageStreamListener + && other.onImage == onImage + && other.onChunk == onChunk + && other.onError == onError; } } diff --git a/packages/flutter/lib/src/painting/inline_span.dart b/packages/flutter/lib/src/painting/inline_span.dart index b31b29349f..4278488d96 100644 --- a/packages/flutter/lib/src/painting/inline_span.dart +++ b/packages/flutter/lib/src/painting/inline_span.dart @@ -358,8 +358,8 @@ abstract class InlineSpan extends DiagnosticableTree { return true; if (other.runtimeType != runtimeType) return false; - final InlineSpan typedOther = other; - return typedOther.style == style; + return other is InlineSpan + && other.style == style; } @override diff --git a/packages/flutter/lib/src/painting/matrix_utils.dart b/packages/flutter/lib/src/painting/matrix_utils.dart index 247aaf5ec1..7f781f23a1 100644 --- a/packages/flutter/lib/src/painting/matrix_utils.dart +++ b/packages/flutter/lib/src/painting/matrix_utils.dart @@ -507,11 +507,11 @@ class MatrixUtils { // Model matrix by first translating the object from the origin of the world // by radius in the z axis and then rotating against the world. - result *= ( + result = result * (( orientation == Axis.horizontal ? Matrix4.rotationY(angle) : Matrix4.rotationX(angle) - ) * Matrix4.translationValues(0.0, 0.0, radius); + ) * Matrix4.translationValues(0.0, 0.0, radius)) as Matrix4; // Essentially perspective * view * model. return result; diff --git a/packages/flutter/lib/src/painting/rounded_rectangle_border.dart b/packages/flutter/lib/src/painting/rounded_rectangle_border.dart index afd21d4ae7..fcd388ac94 100644 --- a/packages/flutter/lib/src/painting/rounded_rectangle_border.dart +++ b/packages/flutter/lib/src/painting/rounded_rectangle_border.dart @@ -126,9 +126,9 @@ class RoundedRectangleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final RoundedRectangleBorder typedOther = other; - return side == typedOther.side - && borderRadius == typedOther.borderRadius; + return other is RoundedRectangleBorder + && other.side == side + && other.borderRadius == borderRadius; } @override @@ -286,10 +286,10 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final _RoundedRectangleToCircleBorder typedOther = other; - return side == typedOther.side - && borderRadius == typedOther.borderRadius - && circleness == typedOther.circleness; + return other is _RoundedRectangleToCircleBorder + && other.side == side + && other.borderRadius == borderRadius + && other.circleness == circleness; } @override diff --git a/packages/flutter/lib/src/painting/shape_decoration.dart b/packages/flutter/lib/src/painting/shape_decoration.dart index 50ae38f452..06cfd2e05f 100644 --- a/packages/flutter/lib/src/painting/shape_decoration.dart +++ b/packages/flutter/lib/src/painting/shape_decoration.dart @@ -193,9 +193,9 @@ class ShapeDecoration extends Decoration { if (a is BoxDecoration) { return ShapeDecoration.lerp(ShapeDecoration.fromBoxDecoration(a), this, t); } else if (a == null || a is ShapeDecoration) { - return ShapeDecoration.lerp(a, this, t); + return ShapeDecoration.lerp(a as ShapeDecoration, this, t); } - return super.lerpFrom(a, t); + return super.lerpFrom(a, t) as ShapeDecoration; } @override @@ -203,9 +203,9 @@ class ShapeDecoration extends Decoration { if (b is BoxDecoration) { return ShapeDecoration.lerp(this, ShapeDecoration.fromBoxDecoration(b), t); } else if (b == null || b is ShapeDecoration) { - return ShapeDecoration.lerp(this, b, t); + return ShapeDecoration.lerp(this, b as ShapeDecoration, t); } - return super.lerpTo(b, t); + return super.lerpTo(b, t) as ShapeDecoration; } /// Linearly interpolate between two shapes. @@ -251,12 +251,12 @@ class ShapeDecoration extends Decoration { return true; if (runtimeType != other.runtimeType) return false; - final ShapeDecoration typedOther = other; - return color == typedOther.color - && gradient == typedOther.gradient - && image == typedOther.image - && shadows == typedOther.shadows - && shape == typedOther.shape; + return other is ShapeDecoration + && other.color == color + && other.gradient == gradient + && other.image == image + && other.shadows == shadows + && other.shape == shape; } @override diff --git a/packages/flutter/lib/src/painting/stadium_border.dart b/packages/flutter/lib/src/painting/stadium_border.dart index ce8f4c7322..77b69d38fa 100644 --- a/packages/flutter/lib/src/painting/stadium_border.dart +++ b/packages/flutter/lib/src/painting/stadium_border.dart @@ -53,7 +53,7 @@ class StadiumBorder extends ShapeBorder { if (a is RoundedRectangleBorder) { return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), - borderRadius: a.borderRadius, + borderRadius: a.borderRadius as BorderRadius, rectness: 1.0 - t, ); } @@ -74,7 +74,7 @@ class StadiumBorder extends ShapeBorder { if (b is RoundedRectangleBorder) { return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), - borderRadius: b.borderRadius, + borderRadius: b.borderRadius as BorderRadius, rectness: t, ); } @@ -113,8 +113,8 @@ class StadiumBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final StadiumBorder typedOther = other; - return side == typedOther.side; + return other is StadiumBorder + && other.side == side; } @override @@ -260,9 +260,9 @@ class _StadiumToCircleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final _StadiumToCircleBorder typedOther = other; - return side == typedOther.side - && circleness == typedOther.circleness; + return other is _StadiumToCircleBorder + && other.side == side + && other.circleness == circleness; } @override @@ -402,10 +402,10 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final _StadiumToRoundedRectangleBorder typedOther = other; - return side == typedOther.side - && borderRadius == typedOther.borderRadius - && rectness == typedOther.rectness; + return other is _StadiumToRoundedRectangleBorder + && other.side == side + && other.borderRadius == borderRadius + && other.rectness == rectness; } @override diff --git a/packages/flutter/lib/src/painting/strut_style.dart b/packages/flutter/lib/src/painting/strut_style.dart index 3cd4f57984..fa163dc444 100644 --- a/packages/flutter/lib/src/painting/strut_style.dart +++ b/packages/flutter/lib/src/painting/strut_style.dart @@ -546,14 +546,14 @@ class StrutStyle extends Diagnosticable { return true; if (other.runtimeType != runtimeType) return false; - final StrutStyle typedOther = other; - return fontFamily == typedOther.fontFamily && - fontSize == typedOther.fontSize && - fontWeight == typedOther.fontWeight && - fontStyle == typedOther.fontStyle && - height == typedOther.height && - leading == typedOther.leading && - forceStrutHeight == typedOther.forceStrutHeight; + return other is StrutStyle + && other.fontFamily == fontFamily + && other.fontSize == fontSize + && other.fontWeight == fontWeight + && other.fontStyle == fontStyle + && other.height == height + && other.leading == leading + && other.forceStrutHeight == forceStrutHeight; } @override diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 24a70d45e2..2fd8a8d2fa 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -549,7 +549,7 @@ class TextPainter { _lastMaxWidth = maxWidth; _paragraph.layout(ui.ParagraphConstraints(width: maxWidth)); if (minWidth != maxWidth) { - final double newWidth = maxIntrinsicWidth.clamp(minWidth, maxWidth); + final double newWidth = maxIntrinsicWidth.clamp(minWidth, maxWidth) as double; if (newWidth != width) { _paragraph.layout(ui.ParagraphConstraints(width: newWidth)); } diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index 433fd65c6f..93d49d02a0 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -261,7 +261,7 @@ class TextSpan extends InlineSpan { child is TextSpan, 'visitTextSpan is deprecated. Use visitChildren to support InlineSpans', ); - final TextSpan textSpanChild = child; + final TextSpan textSpanChild = child as TextSpan; if (!textSpanChild.visitTextSpan(visitor)) return false; } @@ -388,7 +388,7 @@ class TextSpan extends InlineSpan { return RenderComparison.identical; if (other.runtimeType != runtimeType) return RenderComparison.layout; - final TextSpan textSpan = other; + final TextSpan textSpan = other as TextSpan; if (textSpan.text != text || children?.length != textSpan.children?.length || (style == null) != (textSpan.style == null)) @@ -423,11 +423,11 @@ class TextSpan extends InlineSpan { return false; if (super != other) return false; - final TextSpan typedOther = other; - return typedOther.text == text - && typedOther.recognizer == recognizer - && typedOther.semanticsLabel == semanticsLabel - && listEquals(typedOther.children, children); + return other is TextSpan + && other.text == text + && other.recognizer == recognizer + && other.semanticsLabel == semanticsLabel + && listEquals(other.children, children); } @override diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 939e4797b3..3e9bc2cd4a 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -833,7 +833,7 @@ class TextStyle extends Diagnosticable { fontFamily: fontFamily ?? this.fontFamily, fontFamilyFallback: fontFamilyFallback ?? this.fontFamilyFallback, fontSize: fontSize == null ? null : fontSize * fontSizeFactor + fontSizeDelta, - fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1)], + fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1) as int], fontStyle: fontStyle, letterSpacing: letterSpacing == null ? null : letterSpacing * letterSpacingFactor + letterSpacingDelta, wordSpacing: wordSpacing == null ? null : wordSpacing * wordSpacingFactor + wordSpacingDelta, @@ -1144,28 +1144,28 @@ class TextStyle extends Diagnosticable { return true; if (other.runtimeType != runtimeType) return false; - final TextStyle typedOther = other; - return inherit == typedOther.inherit && - color == typedOther.color && - backgroundColor == typedOther.backgroundColor && - fontFamily == typedOther.fontFamily && - fontSize == typedOther.fontSize && - fontWeight == typedOther.fontWeight && - fontStyle == typedOther.fontStyle && - letterSpacing == typedOther.letterSpacing && - wordSpacing == typedOther.wordSpacing && - textBaseline == typedOther.textBaseline && - height == typedOther.height && - locale == typedOther.locale && - foreground == typedOther.foreground && - background == typedOther.background && - decoration == typedOther.decoration && - decorationColor == typedOther.decorationColor && - decorationStyle == typedOther.decorationStyle && - decorationThickness == typedOther.decorationThickness && - listEquals(shadows, typedOther.shadows) && - listEquals(fontFeatures, typedOther.fontFeatures) && - listEquals(fontFamilyFallback, typedOther.fontFamilyFallback); + return other is TextStyle + && other.inherit == inherit + && other.color == color + && other.backgroundColor == backgroundColor + && other.fontFamily == fontFamily + && other.fontSize == fontSize + && other.fontWeight == fontWeight + && other.fontStyle == fontStyle + && other.letterSpacing == letterSpacing + && other.wordSpacing == wordSpacing + && other.textBaseline == textBaseline + && other.height == height + && other.locale == locale + && other.foreground == foreground + && other.background == background + && other.decoration == decoration + && other.decorationColor == decorationColor + && other.decorationStyle == decorationStyle + && other.decorationThickness == decorationThickness + && listEquals(other.shadows, shadows) + && listEquals(other.fontFeatures, fontFeatures) + && listEquals(other.fontFamilyFallback, fontFamilyFallback); } @override