Unverified Commit 649e1885 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false in flutter/lib/src/painting (#45621)

parent d01de941
......@@ -44,7 +44,7 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
final StreamController<ImageChunkEvent> chunkEvents = StreamController<ImageChunkEvent>();
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<image_provider.NetworkIm
bool operator ==(dynamic other) {
if (other.runtimeType != runtimeType)
return false;
final NetworkImage typedOther = other;
return url == typedOther.url
&& scale == typedOther.scale;
return other is NetworkImage
&& other.url == url
&& other.scale == scale;
}
@override
......
......@@ -38,12 +38,12 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
@override
ImageStreamCompleter load(image_provider.NetworkImage key, image_provider.DecoderCallback decode) {
return MultiFrameImageStreamCompleter(
codec: _loadAsync(key, decode),
codec: _loadAsync(key as NetworkImage, decode),
scale: key.scale,
informationCollector: () {
return <DiagnosticsNode>[
DiagnosticsProperty<image_provider.ImageProvider>('Image provider', this),
DiagnosticsProperty<NetworkImage>('Image key', key),
DiagnosticsProperty<NetworkImage>('Image key', key as NetworkImage),
];
},
);
......@@ -55,13 +55,13 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
// Web does not support decoding network images to a specified size. The decode parameter
// here is ignored and the web-only `ui.webOnlyInstantiateImageCodecFromUrl` will be used
// directly in place of the typical `instantiateImageCodec` method.
Future<ui.Codec> _loadAsync(NetworkImage key, image_provider.DecoderCallback decode) async {
Future<ui.Codec> _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<ui.Codec>; // ignore: undefined_function
}
@override
......@@ -69,8 +69,9 @@ class NetworkImage extends image_provider.ImageProvider<image_provider.NetworkIm
if (other.runtimeType != runtimeType) {
return false;
}
final NetworkImage typedOther = other;
return url == typedOther.url && scale == typedOther.scale;
return other is NetworkImage
&& other.url == url
&& other.scale == scale;
}
@override
......
......@@ -127,12 +127,10 @@ abstract class AlignmentGeometry {
@override
bool operator ==(dynamic other) {
if (other is! AlignmentGeometry)
return false;
final AlignmentGeometry typedOther = other;
return _x == typedOther._x &&
_start == typedOther._start &&
_y == typedOther._y;
return other is AlignmentGeometry
&& other._x == _x
&& other._start == _start
&& other._y == _y;
}
@override
......
......@@ -136,9 +136,9 @@ class BeveledRectangleBorder extends ShapeBorder {
bool operator ==(dynamic other) {
if (runtimeType != other.runtimeType)
return false;
final BeveledRectangleBorder typedOther = other;
return side == typedOther.side
&& borderRadius == typedOther.borderRadius;
return other is BeveledRectangleBorder
&& other.side == side
&& other.borderRadius == borderRadius;
}
@override
......
......@@ -113,8 +113,8 @@ mixin PaintingBinding on BindingBase, ServicesBinding {
@override
Future<void> handleSystemMessage(Object systemMessage) async {
await super.handleSystemMessage(systemMessage);
final Map<String, dynamic> message = systemMessage;
final String type = message['type'];
final Map<String, dynamic> message = systemMessage as Map<String, dynamic>;
final String type = message['type'] as String;
switch (type) {
case 'fontsChange':
_systemFonts.notifyListeners();
......
......@@ -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
......
......@@ -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<ShapeBorder>(other.borders, borders);
}
@override
......
......@@ -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
......
......@@ -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,
);
}
......
......@@ -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
......
......@@ -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
......
......@@ -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<T> extends Color {
return true;
if (other.runtimeType != runtimeType)
return false;
final ColorSwatch<T> typedOther = other;
return super == other && _swatch == typedOther._swatch;
return super == other
&& other is ColorSwatch<T>
&& other._swatch == _swatch;
}
@override
......
......@@ -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
......
......@@ -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));
......
......@@ -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
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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<Color>(other.colors, colors)
&& listEquals<double>(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<Color>(other.colors, colors)
&& listEquals<double>(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<Color>(other.colors, colors)
&& listEquals<double>(other.stops, stops);
}
@override
......
......@@ -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<FileImage> {
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<MemoryImage> {
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
......
......@@ -219,11 +219,11 @@ class AssetImage extends AssetBundleImageProvider {
if (jsonData == null)
return SynchronousFuture<Map<String, List<String>>>(null);
// TODO(ianh): JSON decoding really shouldn't be on the main thread.
final Map<String, dynamic> parsedJson = json.decode(jsonData);
final Map<String, dynamic> parsedJson = json.decode(jsonData) as Map<String, dynamic>;
final Iterable<String> keys = parsedJson.keys;
final Map<String, List<String>> parsedManifest =
Map<String, List<String>>.fromIterables(keys,
keys.map<List<String>>((String key) => List<String>.from(parsedJson[key])));
keys.map<List<String>>((String key) => List<String>.from(parsedJson[key] as List<dynamic>)));
// TODO(ianh): convert that data structure to the right types.
return SynchronousFuture<Map<String, List<String>>>(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
......
......@@ -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;
}
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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));
}
......
......@@ -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<InlineSpan>(typedOther.children, children);
return other is TextSpan
&& other.text == text
&& other.recognizer == recognizer
&& other.semanticsLabel == semanticsLabel
&& listEquals<InlineSpan>(other.children, children);
}
@override
......
......@@ -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
......
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