Unverified Commit 32464aa3 authored by Paul Berry's avatar Paul Berry Committed by GitHub

Ignore unnecessary casts that can go away soon. (#64200)

parent e1ae4dfc
......@@ -397,7 +397,7 @@ class AnimationController extends Animation<double>
}
void _internalSetValue(double newValue) {
_value = newValue.clamp(lowerBound, upperBound) as double;
_value = newValue.clamp(lowerBound, upperBound) as double; // ignore: unnecessary_cast
if (_value == lowerBound) {
_status = AnimationStatus.dismissed;
} else if (_value == upperBound) {
......@@ -581,7 +581,7 @@ class AnimationController extends Animation<double>
stop();
if (simulationDuration == Duration.zero) {
if (value != target) {
_value = target.clamp(lowerBound, upperBound) as double;
_value = target.clamp(lowerBound, upperBound) as double; // ignore: unnecessary_cast
notifyListeners();
}
_status = (_direction == _AnimationDirection.forward) ?
......@@ -710,7 +710,7 @@ class AnimationController extends Animation<double>
assert(!isAnimating);
_simulation = simulation;
_lastElapsedDuration = Duration.zero;
_value = simulation.x(0.0).clamp(lowerBound, upperBound) as double;
_value = simulation.x(0.0).clamp(lowerBound, upperBound) as double; // ignore: unnecessary_cast
final TickerFuture result = _ticker!.start();
_status = (_direction == _AnimationDirection.forward) ?
AnimationStatus.forward :
......@@ -787,7 +787,7 @@ class AnimationController extends Animation<double>
_lastElapsedDuration = elapsed;
final double elapsedInSeconds = elapsed.inMicroseconds.toDouble() / Duration.microsecondsPerSecond;
assert(elapsedInSeconds >= 0.0);
_value = _simulation!.x(elapsedInSeconds).clamp(lowerBound, upperBound) as double;
_value = _simulation!.x(elapsedInSeconds).clamp(lowerBound, upperBound) as double; // ignore: unnecessary_cast
if (_simulation!.isDone(elapsedInSeconds)) {
_status = (_direction == _AnimationDirection.forward) ?
AnimationStatus.completed :
......@@ -822,7 +822,7 @@ class _InterpolationSimulation extends Simulation {
@override
double x(double timeInSeconds) {
final double t = (timeInSeconds / _durationInSeconds).clamp(0.0, 1.0) as double;
final double t = (timeInSeconds / _durationInSeconds).clamp(0.0, 1.0) as double; // ignore: unnecessary_cast
if (t == 0.0)
return _begin;
else if (t == 1.0)
......
......@@ -182,7 +182,7 @@ class Interval extends Curve {
assert(end >= 0.0);
assert(end <= 1.0);
assert(end >= begin);
t = ((t - begin) / (end - begin)).clamp(0.0, 1.0) as double;
t = ((t - begin) / (end - begin)).clamp(0.0, 1.0) as double; // ignore: unnecessary_cast
if (t == 0.0 || t == 1.0)
return t;
return curve.transform(t);
......@@ -1189,7 +1189,7 @@ class ElasticInCurve extends Curve {
double transformInternal(double t) {
final double s = period / 4.0;
t = t - 1.0;
return -math.pow(2.0, 10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period) as double;
return -math.pow(2.0, 10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period) as double; // ignore: unnecessary_cast
}
@override
......@@ -1216,7 +1216,7 @@ class ElasticOutCurve extends Curve {
@override
double transformInternal(double t) {
final double s = period / 4.0;
return math.pow(2.0, -10 * t) * math.sin((t - s) * (math.pi * 2.0) / period) + 1.0 as double;
return math.pow(2.0, -10 * t) * math.sin((t - s) * (math.pi * 2.0) / period) + 1.0 as double; // ignore: unnecessary_cast
}
@override
......@@ -1248,7 +1248,7 @@ class ElasticInOutCurve extends Curve {
if (t < 0.0)
return -0.5 * math.pow(2.0, 10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period);
else
return math.pow(2.0, -10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period) * 0.5 + 1.0 as double;
return math.pow(2.0, -10.0 * t) * math.sin((t - s) * (math.pi * 2.0) / period) * 0.5 + 1.0 as double; // ignore: unnecessary_cast
}
@override
......
......@@ -341,7 +341,7 @@ class ForcePressGestureRecognizer extends OneSequenceGestureRecognizer {
// If the device incorrectly reports a pressure outside of pressureMin
// and pressureMax, we still want this recognizer to respond normally.
if (!value.isNaN)
value = value.clamp(0.0, 1.0) as double;
value = value.clamp(0.0, 1.0) as double; // ignore: unnecessary_cast
return value;
}
......
......@@ -207,10 +207,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) as double,
lerpDouble(a.alpha, b.alpha, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
lerpDouble(a.hue, b.hue, t)! % 360.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,
lerpDouble(a.saturation, b.saturation, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
lerpDouble(a.value, b.value, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
);
}
......@@ -291,7 +291,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) as double);
: ((delta / (1.0 - (2.0 * lightness - 1.0).abs())).clamp(0.0, 1.0) as double); // ignore: unnecessary_cast
return HSLColor.fromAHSL(alpha, hue, saturation, lightness);
}
......@@ -391,10 +391,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) as double,
lerpDouble(a.alpha, b.alpha, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
lerpDouble(a.hue, b.hue, t)! % 360.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,
lerpDouble(a.saturation, b.saturation, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
lerpDouble(a.lightness, b.lightness, t)!.clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
);
}
......
......@@ -162,12 +162,12 @@ abstract class EdgeInsetsGeometry {
/// or equal to `min`, and less than or equal to `max`.
EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
return _MixedEdgeInsets.fromLRSETB(
_left.clamp(min._left, max._left) as double,
_right.clamp(min._right, max._right) as double,
_start.clamp(min._start, max._start) as double,
_end.clamp(min._end, max._end) as double,
_top.clamp(min._top, max._top) as double,
_bottom.clamp(min._bottom, max._bottom) as double,
_left.clamp(min._left, max._left) as double, // ignore: unnecessary_cast
_right.clamp(min._right, max._right) as double, // ignore: unnecessary_cast
_start.clamp(min._start, max._start) as double, // ignore: unnecessary_cast
_end.clamp(min._end, max._end) as double, // ignore: unnecessary_cast
_top.clamp(min._top, max._top) as double, // ignore: unnecessary_cast
_bottom.clamp(min._bottom, max._bottom) as double, // ignore: unnecessary_cast
);
}
......@@ -506,10 +506,10 @@ class EdgeInsets extends EdgeInsetsGeometry {
@override
EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
return EdgeInsets.fromLTRB(
_left.clamp(min._left, max._left) as double,
_top.clamp(min._top, max._top) as double,
_right.clamp(min._right, max._right) as double,
_bottom.clamp(min._bottom, max._bottom) as double,
_left.clamp(min._left, max._left) as double, // ignore: unnecessary_cast
_top.clamp(min._top, max._top) as double, // ignore: unnecessary_cast
_right.clamp(min._right, max._right) as double, // ignore: unnecessary_cast
_bottom.clamp(min._bottom, max._bottom) as double, // ignore: unnecessary_cast
);
}
......
......@@ -139,7 +139,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) as double,
(a._opacity + (b._opacity - a._opacity) * t).clamp(0.0, 1.0) as double, // ignore: unnecessary_cast
);
}
......
......@@ -65,7 +65,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) as double;
final double normalizedTargetX = target.dx.clamp(margin, size.width - margin) as double; // ignore: unnecessary_cast
final double edge = margin + childSize.width / 2.0;
if (normalizedTargetX < edge) {
x = margin;
......
......@@ -580,7 +580,7 @@ class TextPainter {
newWidth = maxIntrinsicWidth;
break;
}
newWidth = newWidth.clamp(minWidth, maxWidth) as double;
newWidth = newWidth.clamp(minWidth, maxWidth) as double; // ignore: unnecessary_cast
if (newWidth != _applyFloatingPointHack(_paragraph!.width)) {
_paragraph!.layout(ui.ParagraphConstraints(width: newWidth));
}
......
......@@ -839,7 +839,7 @@ class TextStyle with 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) as int],
fontWeight: fontWeight == null ? null : FontWeight.values[(fontWeight!.index + fontWeightDelta).clamp(0, FontWeight.values.length - 1) as int], // ignore: unnecessary_cast
fontStyle: fontStyle ?? this.fontStyle,
letterSpacing: letterSpacing == null ? null : letterSpacing! * letterSpacingFactor + letterSpacingDelta,
wordSpacing: wordSpacing == null ? null : wordSpacing! * wordSpacingFactor + wordSpacingDelta,
......
......@@ -48,10 +48,10 @@ class ClampedSimulation extends Simulation {
final double dxMax;
@override
double x(double time) => simulation.x(time).clamp(xMin, xMax) as double;
double x(double time) => simulation.x(time).clamp(xMin, xMax) as double; // ignore: unnecessary_cast
@override
double dx(double time) => simulation.dx(time).clamp(dxMin, dxMax) as double;
double dx(double time) => simulation.dx(time).clamp(dxMin, dxMax) as double; // ignore: unnecessary_cast
@override
bool isDone(double time) => simulation.isDone(time);
......
......@@ -116,7 +116,7 @@ class BoundedFrictionSimulation extends FrictionSimulation {
@override
double x(double time) {
return super.x(time).clamp(_minX, _maxX) as double;
return super.x(time).clamp(_minX, _maxX) as double; // ignore: unnecessary_cast
}
@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