Unverified Commit d81d9160 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

implicit-casts:false in flutter/lib/src/material (#45567)

* implicit-casts:false in flutter/lib/src/material

* address review comments
parent 0497235c
......@@ -104,7 +104,7 @@ class AnimatedIcon extends StatelessWidget {
@override
Widget build(BuildContext context) {
final _AnimatedIconData iconData = icon;
final _AnimatedIconData iconData = icon as _AnimatedIconData;
final IconThemeData iconTheme = IconTheme.of(context);
final double iconSize = size ?? iconTheme.size;
final TextDirection textDirection = this.textDirection ?? Directionality.of(context);
......@@ -161,7 +161,7 @@ class _AnimatedIconPainter extends CustomPainter {
canvas.translate(-size.width, -size.height);
}
final double clampedProgress = progress.value.clamp(0.0, 1.0);
final double clampedProgress = progress.value.clamp(0.0, 1.0) as double;
for (_PathFrames path in paths)
path.paint(canvas, color, uiPathFactory, clampedProgress);
}
......
......@@ -750,7 +750,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
// 1 | 1 | 0 || 1.0
// 1 | 1 | 1 || fade
final double toolbarOpacity = !pinned || (floating && bottom != null)
? ((visibleMainHeight - _bottomHeight) / kToolbarHeight).clamp(0.0, 1.0)
? ((visibleMainHeight - _bottomHeight) / kToolbarHeight).clamp(0.0, 1.0) as double
: 1.0;
final Widget appBar = FlexibleSpaceBar.createSettings(
......@@ -778,7 +778,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
titleSpacing: titleSpacing,
shape: shape,
toolbarOpacity: toolbarOpacity,
bottomOpacity: pinned ? 1.0 : (visibleMainHeight / _bottomHeight).clamp(0.0, 1.0),
bottomOpacity: pinned ? 1.0 : ((visibleMainHeight / _bottomHeight).clamp(0.0, 1.0) as double),
),
);
return floating ? _FloatingAppBar(child: appBar) : appBar;
......
......@@ -128,13 +128,13 @@ class AppBarTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final AppBarTheme typedOther = other;
return typedOther.brightness == brightness
&& typedOther.color == color
&& typedOther.elevation == elevation
&& typedOther.iconTheme == iconTheme
&& typedOther.actionsIconTheme == actionsIconTheme
&& typedOther.textTheme == textTheme;
return other is AppBarTheme
&& other.brightness == brightness
&& other.color == color
&& other.elevation == elevation
&& other.iconTheme == iconTheme
&& other.actionsIconTheme == actionsIconTheme
&& other.textTheme == textTheme;
}
@override
......
......@@ -193,14 +193,14 @@ const List<_Diagonal> _allDiagonals = <_Diagonal>[
_Diagonal(_CornerId.bottomLeft, _CornerId.topRight),
];
typedef _KeyFunc<T> = dynamic Function(T input);
typedef _KeyFunc<T> = double Function(T input);
// Select the element for which the key function returns the maximum value.
T _maxBy<T>(Iterable<T> input, _KeyFunc<T> keyFunc) {
T maxValue;
dynamic maxKey;
double maxKey;
for (T value in input) {
final dynamic key = keyFunc(value);
final double key = keyFunc(value);
if (maxKey == null || key > maxKey) {
maxValue = value;
maxKey = key;
......
......@@ -73,8 +73,8 @@ class MaterialBannerThemeData extends Diagnosticable {
return MaterialBannerThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
padding: EdgeInsets.lerp(a?.padding, b?.padding, t),
leadingPadding: EdgeInsets.lerp(a?.leadingPadding, b?.leadingPadding, t),
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
leadingPadding: EdgeInsetsGeometry.lerp(a?.leadingPadding, b?.leadingPadding, t),
);
}
......@@ -94,11 +94,11 @@ class MaterialBannerThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final MaterialBannerThemeData typedOther = other;
return typedOther.backgroundColor == backgroundColor
&& typedOther.contentTextStyle == contentTextStyle
&& typedOther.padding == padding
&& typedOther.leadingPadding == leadingPadding;
return other is MaterialBannerThemeData
&& other.backgroundColor == backgroundColor
&& other.contentTextStyle == contentTextStyle
&& other.padding == padding
&& other.leadingPadding == leadingPadding;
}
@override
......
......@@ -92,10 +92,10 @@ class BottomAppBarTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final BottomAppBarTheme typedOther = other;
return typedOther.color == color
&& typedOther.elevation == elevation
&& typedOther.shape == shape;
return other is BottomAppBarTheme
&& other.color == color
&& other.elevation == elevation
&& other.shape == shape;
}
@override
......
......@@ -152,7 +152,7 @@ class _BottomSheetState extends State<BottomSheet> {
final GlobalKey _childKey = GlobalKey(debugLabel: 'BottomSheet child');
double get _childHeight {
final RenderBox renderBox = _childKey.currentContext.findRenderObject();
final RenderBox renderBox = _childKey.currentContext.findRenderObject() as RenderBox;
return renderBox.size.height;
}
......
......@@ -123,13 +123,13 @@ class BottomSheetThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final BottomSheetThemeData typedOther = other;
return typedOther.backgroundColor == backgroundColor
&& typedOther.elevation == elevation
&& typedOther.modalBackgroundColor == modalBackgroundColor
&& typedOther.modalElevation == modalElevation
&& typedOther.shape == shape
&& typedOther.clipBehavior == clipBehavior;
return other is BottomSheetThemeData
&& other.backgroundColor == backgroundColor
&& other.elevation == elevation
&& other.modalBackgroundColor == modalBackgroundColor
&& other.modalElevation == modalElevation
&& other.shape == shape
&& other.clipBehavior == clipBehavior;
}
@override
......
......@@ -367,8 +367,8 @@ class _RawMaterialButtonState extends State<RawMaterialButton> {
final ShapeBorder effectiveShape = MaterialStateProperty.resolveAs<ShapeBorder>(widget.shape, _states);
final Offset densityAdjustment = widget.visualDensity.baseSizeAdjustment;
final BoxConstraints effectiveConstraints = widget.constraints.copyWith(
minWidth: widget.constraints.minWidth != null ? (widget.constraints.minWidth + densityAdjustment.dx).clamp(0.0, double.infinity) : null,
minHeight: widget.constraints.minWidth != null ? (widget.constraints.minHeight + densityAdjustment.dy).clamp(0.0, double.infinity) : null,
minWidth: widget.constraints.minWidth != null ? (widget.constraints.minWidth + densityAdjustment.dx).clamp(0.0, double.infinity) as double : null,
minHeight: widget.constraints.minWidth != null ? (widget.constraints.minHeight + densityAdjustment.dy).clamp(0.0, double.infinity) as double : null,
);
final EdgeInsetsGeometry padding = widget.padding.add(
EdgeInsets.only(
......@@ -517,8 +517,8 @@ class _RenderInputPadding extends RenderShiftedBox {
final double height = math.max(child.size.width, minSize.width);
final double width = math.max(child.size.height, minSize.height);
size = constraints.constrain(Size(height, width));
final BoxParentData childParentData = child.parentData;
childParentData.offset = Alignment.center.alongOffset(size - child.size);
final BoxParentData childParentData = child.parentData as BoxParentData;
childParentData.offset = Alignment.center.alongOffset(size - child.size as Offset);
} else {
size = Size.zero;
}
......
......@@ -316,7 +316,7 @@ class _RenderButtonBarRow extends RenderFlex {
double currentHeight = 0.0;
while (child != null) {
final FlexParentData childParentData = child.parentData;
final FlexParentData childParentData = child.parentData as FlexParentData;
// Lay out the child with the button bar's original constraints, but
// with minimum width set to zero.
......
......@@ -136,7 +136,7 @@ class ButtonBarThemeData extends Diagnosticable {
buttonTextTheme: t < 0.5 ? a.buttonTextTheme : b.buttonTextTheme,
buttonMinWidth: lerpDouble(a?.buttonMinWidth, b?.buttonMinWidth, t),
buttonHeight: lerpDouble(a?.buttonHeight, b?.buttonHeight, t),
buttonPadding: EdgeInsets.lerp(a?.buttonPadding, b?.buttonPadding, t),
buttonPadding: EdgeInsetsGeometry.lerp(a?.buttonPadding, b?.buttonPadding, t),
buttonAlignedDropdown: t < 0.5 ? a.buttonAlignedDropdown : b.buttonAlignedDropdown,
layoutBehavior: t < 0.5 ? a.layoutBehavior : b.layoutBehavior,
);
......@@ -162,15 +162,15 @@ class ButtonBarThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final ButtonBarThemeData typedOther = other;
return typedOther.alignment == alignment
&& typedOther.mainAxisSize == mainAxisSize
&& typedOther.buttonTextTheme == buttonTextTheme
&& typedOther.buttonMinWidth == buttonMinWidth
&& typedOther.buttonHeight == buttonHeight
&& typedOther.buttonPadding == buttonPadding
&& typedOther.buttonAlignedDropdown == buttonAlignedDropdown
&& typedOther.layoutBehavior == layoutBehavior;
return other is ButtonBarThemeData
&& other.alignment == alignment
&& other.mainAxisSize == mainAxisSize
&& other.buttonTextTheme == buttonTextTheme
&& other.buttonMinWidth == buttonMinWidth
&& other.buttonHeight == buttonHeight
&& other.buttonPadding == buttonPadding
&& other.buttonAlignedDropdown == buttonAlignedDropdown
&& other.layoutBehavior == layoutBehavior;
}
@override
......
......@@ -907,21 +907,21 @@ class ButtonThemeData extends Diagnosticable {
bool operator ==(dynamic other) {
if (other.runtimeType != runtimeType)
return false;
final ButtonThemeData typedOther = other;
return textTheme == typedOther.textTheme
&& minWidth == typedOther.minWidth
&& height == typedOther.height
&& padding == typedOther.padding
&& shape == typedOther.shape
&& alignedDropdown == typedOther.alignedDropdown
&& _buttonColor == typedOther._buttonColor
&& _disabledColor == typedOther._disabledColor
&& _focusColor == typedOther._focusColor
&& _hoverColor == typedOther._hoverColor
&& _highlightColor == typedOther._highlightColor
&& _splashColor == typedOther._splashColor
&& colorScheme == typedOther.colorScheme
&& _materialTapTargetSize == typedOther._materialTapTargetSize;
return other is ButtonThemeData
&& other.textTheme == textTheme
&& other.minWidth == minWidth
&& other.height == height
&& other.padding == padding
&& other.shape == shape
&& other.alignedDropdown == alignedDropdown
&& other._buttonColor == _buttonColor
&& other._disabledColor == _disabledColor
&& other._focusColor == _focusColor
&& other._hoverColor == _hoverColor
&& other._highlightColor == _highlightColor
&& other._splashColor == _splashColor
&& other.colorScheme == colorScheme
&& other._materialTapTargetSize == _materialTapTargetSize;
}
@override
......
......@@ -122,12 +122,12 @@ class CardTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final CardTheme typedOther = other;
return typedOther.clipBehavior == clipBehavior
&& typedOther.color == color
&& typedOther.elevation == elevation
&& typedOther.margin == margin
&& typedOther.shape == shape;
return other is CardTheme
&& other.clipBehavior == clipBehavior
&& other.color == color
&& other.elevation == elevation
&& other.margin == margin
&& other.shape == shape;
}
@override
......
......@@ -458,7 +458,7 @@ class _RenderCheckbox extends RenderToggleable {
paintRadialReaction(canvas, offset, size.center(Offset.zero));
final Paint strokePaint = _createStrokePaint();
final Offset origin = offset + (size / 2.0 - const Size.square(_kEdgeSize) / 2.0);
final Offset origin = offset + (size / 2.0 - const Size.square(_kEdgeSize) / 2.0 as Offset);
final AnimationStatus status = position.status;
final double tNormalized = status == AnimationStatus.forward || status == AnimationStatus.completed
? position.value
......
......@@ -1532,7 +1532,7 @@ class RawChip extends StatefulWidget
@override
final Color checkmarkColor;
@override
final CircleBorder avatarBorder;
final ShapeBorder avatarBorder;
/// If set, this indicates that the chip should be disabled if all of the
/// tap callbacks ([onSelected], [onPressed]) are null.
......@@ -2045,10 +2045,10 @@ class _RenderChipElement extends RenderObjectElement {
final Map<Element, _ChipSlot> childToSlot = <Element, _ChipSlot>{};
@override
_ChipRenderWidget get widget => super.widget;
_ChipRenderWidget get widget => super.widget as _ChipRenderWidget;
@override
_RenderChip get renderObject => super.renderObject;
_RenderChip get renderObject => super.renderObject as _RenderChip;
@override
void visitChildren(ElementVisitor visitor) {
......@@ -2110,13 +2110,13 @@ class _RenderChipElement extends RenderObjectElement {
void _updateRenderObject(RenderObject child, _ChipSlot slot) {
switch (slot) {
case _ChipSlot.avatar:
renderObject.avatar = child;
renderObject.avatar = child as RenderBox;
break;
case _ChipSlot.label:
renderObject.label = child;
renderObject.label = child as RenderBox;
break;
case _ChipSlot.deleteIcon:
renderObject.deleteIcon = child;
renderObject.deleteIcon = child as RenderBox;
break;
}
}
......@@ -2125,7 +2125,7 @@ class _RenderChipElement extends RenderObjectElement {
void insertChildRenderObject(RenderObject child, dynamic slotValue) {
assert(child is RenderBox);
assert(slotValue is _ChipSlot);
final _ChipSlot slot = slotValue;
final _ChipSlot slot = slotValue as _ChipSlot;
_updateRenderObject(child, slot);
assert(renderObject.childToSlot.keys.contains(child));
assert(renderObject.slotToChild.keys.contains(slot));
......@@ -2181,17 +2181,17 @@ class _ChipRenderTheme {
if (other.runtimeType != runtimeType) {
return false;
}
final _ChipRenderTheme typedOther = other;
return typedOther.avatar == avatar
&& typedOther.label == label
&& typedOther.deleteIcon == deleteIcon
&& typedOther.brightness == brightness
&& typedOther.padding == padding
&& typedOther.labelPadding == labelPadding
&& typedOther.showAvatar == showAvatar
&& typedOther.showCheckmark == showCheckmark
&& typedOther.checkmarkColor == checkmarkColor
&& typedOther.canTapBody == canTapBody;
return other is _ChipRenderTheme
&& other.avatar == avatar
&& other.label == label
&& other.deleteIcon == deleteIcon
&& other.brightness == brightness
&& other.padding == padding
&& other.labelPadding == labelPadding
&& other.showAvatar == showAvatar
&& other.showCheckmark == showCheckmark
&& other.checkmarkColor == checkmarkColor
&& other.canTapBody == canTapBody;
}
@override
......@@ -2373,7 +2373,7 @@ class _RenderChip extends RenderBox {
static Rect _boxRect(RenderBox box) => box == null ? Rect.zero : _boxParentData(box).offset & box.size;
static BoxParentData _boxParentData(RenderBox box) => box.parentData;
static BoxParentData _boxParentData(RenderBox box) => box.parentData as BoxParentData;
@override
double computeMinIntrinsicWidth(double height) {
......@@ -2895,7 +2895,7 @@ class _LocationAwareInkRippleFactory extends InteractiveInkFeatureFactory {
if (tapIsOnDeleteIcon) {
final RenderBox currentBox = referenceBox;
referenceBox = deleteIconKey.currentContext.findRenderObject();
referenceBox = deleteIconKey.currentContext.findRenderObject() as RenderBox;
position = referenceBox.globalToLocal(currentBox.localToGlobal(position));
containedInkWell = false;
}
......
......@@ -484,23 +484,23 @@ class ChipThemeData extends Diagnosticable {
if (other.runtimeType != runtimeType) {
return false;
}
final ChipThemeData otherData = other;
return otherData.backgroundColor == backgroundColor
&& otherData.deleteIconColor == deleteIconColor
&& otherData.disabledColor == disabledColor
&& otherData.selectedColor == selectedColor
&& otherData.secondarySelectedColor == secondarySelectedColor
&& otherData.shadowColor == shadowColor
&& otherData.selectedShadowColor == selectedShadowColor
&& otherData.checkmarkColor == checkmarkColor
&& otherData.labelPadding == labelPadding
&& otherData.padding == padding
&& otherData.shape == shape
&& otherData.labelStyle == labelStyle
&& otherData.secondaryLabelStyle == secondaryLabelStyle
&& otherData.brightness == brightness
&& otherData.elevation == elevation
&& otherData.pressElevation == pressElevation;
return other is ChipThemeData
&& other.backgroundColor == backgroundColor
&& other.deleteIconColor == deleteIconColor
&& other.disabledColor == disabledColor
&& other.selectedColor == selectedColor
&& other.secondarySelectedColor == secondarySelectedColor
&& other.shadowColor == shadowColor
&& other.selectedShadowColor == selectedShadowColor
&& other.checkmarkColor == checkmarkColor
&& other.labelPadding == labelPadding
&& other.padding == padding
&& other.shape == shape
&& other.labelStyle == labelStyle
&& other.secondaryLabelStyle == secondaryLabelStyle
&& other.brightness == brightness
&& other.elevation == elevation
&& other.pressElevation == pressElevation;
}
@override
......
......@@ -268,20 +268,20 @@ class ColorScheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final ColorScheme otherScheme = other;
return otherScheme.primary == primary
&& otherScheme.primaryVariant == primaryVariant
&& otherScheme.secondary == secondary
&& otherScheme.secondaryVariant == secondaryVariant
&& otherScheme.surface == surface
&& otherScheme.background == background
&& otherScheme.error == error
&& otherScheme.onPrimary == onPrimary
&& otherScheme.onSecondary == onSecondary
&& otherScheme.onSurface == onSurface
&& otherScheme.onBackground == onBackground
&& otherScheme.onError == onError
&& otherScheme.brightness == brightness;
return other is ColorScheme
&& other.primary == primary
&& other.primaryVariant == primaryVariant
&& other.secondary == secondary
&& other.secondaryVariant == secondaryVariant
&& other.surface == surface
&& other.background == background
&& other.error == error
&& other.onPrimary == onPrimary
&& other.onSecondary == onSecondary
&& other.onSurface == onSurface
&& other.onBackground == onBackground
&& other.onError == onError
&& other.brightness == brightness;
}
@override
......
......@@ -750,14 +750,14 @@ class TableRowInkWell extends InkResponse {
AbstractNode table = cell.parent;
final Matrix4 transform = Matrix4.identity();
while (table is RenderObject && table is! RenderTable) {
final RenderTable parentBox = table;
final RenderObject parentBox = table as RenderObject;
parentBox.applyPaintTransform(cell, transform);
assert(table == cell.parent);
cell = table;
cell = parentBox;
table = table.parent;
}
if (table is RenderTable) {
final TableCellParentData cellParentData = cell.parentData;
final TableCellParentData cellParentData = cell.parentData as TableCellParentData;
assert(cellParentData.y != null);
final Rect rect = table.getRowBox(cellParentData.y);
// The rect is in the table's coordinate space. We need to change it to the
......
......@@ -109,12 +109,12 @@ class DialogTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final DialogTheme typedOther = other;
return typedOther.backgroundColor == backgroundColor
&& typedOther.elevation == elevation
&& typedOther.shape == shape
&& typedOther.titleTextStyle == titleTextStyle
&& typedOther.contentTextStyle == contentTextStyle;
return other is DialogTheme
&& other.backgroundColor == backgroundColor
&& other.elevation == elevation
&& other.shape == shape
&& other.titleTextStyle == titleTextStyle
&& other.contentTextStyle == contentTextStyle;
}
@override
......
......@@ -110,12 +110,12 @@ class DividerThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final DividerThemeData typedOther = other;
return typedOther.color == color
&& typedOther.space == space
&& typedOther.thickness == thickness
&& typedOther.indent == indent
&& typedOther.endIndent == endIndent;
return other is DividerThemeData
&& other.color == color
&& other.space == space
&& other.thickness == thickness
&& other.indent == indent
&& other.endIndent == endIndent;
}
@override
......
......@@ -381,7 +381,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
final GlobalKey _drawerKey = GlobalKey();
double get _width {
final RenderBox box = _drawerKey.currentContext?.findRenderObject();
final RenderBox box = _drawerKey.currentContext?.findRenderObject() as RenderBox;
if (box != null)
return box.size.width;
return _kWidth; // drawer not being shown currently
......
......@@ -62,12 +62,12 @@ class _DropdownMenuPainter extends CustomPainter {
void paint(Canvas canvas, Size size) {
final double selectedItemOffset = getSelectedItemOffset();
final Tween<double> top = Tween<double>(
begin: selectedItemOffset.clamp(0.0, size.height - _kMenuItemHeight),
begin: selectedItemOffset.clamp(0.0, size.height - _kMenuItemHeight) as double,
end: 0.0,
);
final Tween<double> bottom = Tween<double>(
begin: (top.begin + _kMenuItemHeight).clamp(_kMenuItemHeight, size.height),
begin: (top.begin + _kMenuItemHeight).clamp(_kMenuItemHeight, size.height) as double,
end: size.height,
);
......@@ -162,8 +162,8 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>>
if (widget.itemIndex == widget.route.selectedIndex) {
opacity = CurvedAnimation(parent: widget.route.animation, curve: const Threshold(0.0));
} else {
final double start = (0.5 + (widget.itemIndex + 1) * unit).clamp(0.0, 1.0);
final double end = (start + 1.5 * unit).clamp(0.0, 1.0);
final double start = (0.5 + (widget.itemIndex + 1) * unit).clamp(0.0, 1.0) as double;
final double end = (start + 1.5 * unit).clamp(0.0, 1.0) as double;
opacity = CurvedAnimation(parent: widget.route.animation, curve: Interval(start, end));
}
Widget child = FadeTransition(
......@@ -341,10 +341,10 @@ class _DropdownMenuRouteLayout<T> extends SingleChildLayoutDelegate {
double left;
switch (textDirection) {
case TextDirection.rtl:
left = buttonRect.right.clamp(0.0, size.width) - childSize.width;
left = (buttonRect.right.clamp(0.0, size.width) as double) - childSize.width;
break;
case TextDirection.ltr:
left = buttonRect.left.clamp(0.0, size.width - childSize.width);
left = buttonRect.left.clamp(0.0, size.width - childSize.width) as double;
break;
}
......@@ -367,10 +367,8 @@ class _DropdownRouteResult<T> {
@override
bool operator ==(dynamic other) {
if (other is! _DropdownRouteResult<T>)
return false;
final _DropdownRouteResult<T> typedOther = other;
return result == typedOther.result;
return other is _DropdownRouteResult<T>
&& other.result == result;
}
@override
......@@ -1133,7 +1131,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
TextStyle get _textStyle => widget.style ?? Theme.of(context).textTheme.subhead;
void _handleTap() {
final RenderBox itemBox = context.findRenderObject();
final RenderBox itemBox = context.findRenderObject() as RenderBox;
final Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
final TextDirection textDirection = Directionality.of(context);
final EdgeInsetsGeometry menuMargin = ButtonTheme.of(context).alignedDropdown
......@@ -1476,7 +1474,7 @@ class DropdownButtonFormField<T> extends FormField<T> {
class _DropdownButtonFormFieldState<T> extends FormFieldState<T> {
@override
DropdownButtonFormField<T> get widget => super.widget;
DropdownButtonFormField<T> get widget => super.widget as DropdownButtonFormField<T>;
@override
void didChange(T value) {
......
......@@ -25,9 +25,9 @@ class _SaltedKey<S, V> extends LocalKey {
bool operator ==(dynamic other) {
if (other.runtimeType != runtimeType)
return false;
final _SaltedKey<S, V> typedOther = other;
return salt == typedOther.salt
&& value == typedOther.value;
return other is _SaltedKey<S, V>
&& other.salt == salt
&& other.value == value;
}
@override
......@@ -364,7 +364,8 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
if (widget._allowOnlyOnePanelOpen) {
assert(_allIdentifiersUnique(), 'All ExpansionPanelRadio identifier values must be unique.');
if (widget.initialOpenPanelValue != null) {
_currentOpenPanel = searchPanelByValue(widget.children, widget.initialOpenPanelValue);
_currentOpenPanel =
searchPanelByValue(widget.children.cast<ExpansionPanelRadio>(), widget.initialOpenPanelValue);
}
}
}
......@@ -378,7 +379,8 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
// If the previous widget was non-radio ExpansionPanelList, initialize the
// open panel to widget.initialOpenPanelValue
if (!oldWidget._allowOnlyOnePanelOpen) {
_currentOpenPanel = searchPanelByValue(widget.children, widget.initialOpenPanelValue);
_currentOpenPanel =
searchPanelByValue(widget.children.cast<ExpansionPanelRadio>(), widget.initialOpenPanelValue);
}
} else {
_currentOpenPanel = null;
......@@ -387,7 +389,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
bool _allIdentifiersUnique() {
final Map<Object, bool> identifierMap = <Object, bool>{};
for (ExpansionPanelRadio child in widget.children) {
for (ExpansionPanelRadio child in widget.children.cast<ExpansionPanelRadio>()) {
identifierMap[child.value] = true;
}
return identifierMap.length == widget.children.length;
......@@ -395,7 +397,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
bool _isChildExpanded(int index) {
if (widget._allowOnlyOnePanelOpen) {
final ExpansionPanelRadio radioWidget = widget.children[index];
final ExpansionPanelRadio radioWidget = widget.children[index] as ExpansionPanelRadio;
return _currentOpenPanel?.value == radioWidget.value;
}
return widget.children[index].isExpanded;
......@@ -406,12 +408,12 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
widget.expansionCallback(index, isExpanded);
if (widget._allowOnlyOnePanelOpen) {
final ExpansionPanelRadio pressedChild = widget.children[index];
final ExpansionPanelRadio pressedChild = widget.children[index] as ExpansionPanelRadio;
// If another ExpansionPanelRadio was already open, apply its
// expansionCallback (if any) to false, because it's closing.
for (int childIndex = 0; childIndex < widget.children.length; childIndex += 1) {
final ExpansionPanelRadio child = widget.children[childIndex];
final ExpansionPanelRadio child = widget.children[childIndex] as ExpansionPanelRadio;
if (widget.expansionCallback != null &&
childIndex != index &&
child.value == _currentOpenPanel?.value)
......
......@@ -115,7 +115,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
_iconColor = _controller.drive(_iconColorTween.chain(_easeInTween));
_backgroundColor = _controller.drive(_backgroundColorTween.chain(_easeOutTween));
_isExpanded = PageStorage.of(context)?.readState(context) ?? widget.initiallyExpanded;
_isExpanded = PageStorage.of(context)?.readState(context) as bool ?? widget.initiallyExpanded;
if (_isExpanded)
_controller.value = 1.0;
}
......
......@@ -288,7 +288,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
// 0.0 -> Expanded
// 1.0 -> Collapsed to toolbar
final double t = (1.0 - (settings.currentExtent - settings.minExtent) / deltaExtent).clamp(0.0, 1.0);
final double t = (1.0 - (settings.currentExtent - settings.minExtent) / deltaExtent).clamp(0.0, 1.0) as double;
// background
if (widget.background != null) {
......@@ -358,7 +358,7 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
if (widget.stretchModes.contains(StretchMode.fadeTitle) &&
constraints.maxHeight > settings.maxExtent) {
final double stretchOpacity = 1 -
((constraints.maxHeight - settings.maxExtent) / 100).clamp(0.0, 1.0);
(((constraints.maxHeight - settings.maxExtent) / 100).clamp(0.0, 1.0) as double);
title = Opacity(
opacity: stretchOpacity,
child: title,
......
......@@ -165,18 +165,18 @@ class FloatingActionButtonThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final FloatingActionButtonThemeData otherData = other;
return otherData.foregroundColor == foregroundColor
&& otherData.backgroundColor == backgroundColor
&& otherData.focusColor == focusColor
&& otherData.hoverColor == hoverColor
&& otherData.splashColor == splashColor
&& otherData.elevation == elevation
&& otherData.focusElevation == focusElevation
&& otherData.hoverElevation == hoverElevation
&& otherData.disabledElevation == disabledElevation
&& otherData.highlightElevation == highlightElevation
&& otherData.shape == shape;
return other is FloatingActionButtonThemeData
&& other.foregroundColor == foregroundColor
&& other.backgroundColor == backgroundColor
&& other.focusColor == focusColor
&& other.hoverColor == hoverColor
&& other.splashColor == splashColor
&& other.elevation == elevation
&& other.focusElevation == focusElevation
&& other.hoverElevation == hoverElevation
&& other.disabledElevation == disabledElevation
&& other.highlightElevation == highlightElevation
&& other.shape == shape;
}
@override
......
......@@ -252,7 +252,7 @@ class _InkState extends State<Ink> {
decoration: widget.decoration,
configuration: createLocalImageConfiguration(context),
controller: Material.of(context),
referenceBox: context.findRenderObject(),
referenceBox: context.findRenderObject() as RenderBox,
onRemoved: _handleRemoved,
);
} else {
......
......@@ -511,7 +511,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
}
@override
void didUpdateWidget(InkResponse oldWidget) {
void didUpdateWidget(T oldWidget) {
super.didUpdateWidget(oldWidget);
if (_isWidgetEnabled(widget) != _isWidgetEnabled(oldWidget)) {
_handleHoverChange(_hovering);
......@@ -565,7 +565,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
return;
if (value) {
if (highlight == null) {
final RenderBox referenceBox = context.findRenderObject();
final RenderBox referenceBox = context.findRenderObject() as RenderBox;
_highlights[type] = InkHighlight(
controller: Material.of(context),
referenceBox: referenceBox,
......@@ -603,7 +603,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
InteractiveInkFeature _createInkFeature(Offset globalPosition) {
final MaterialInkController inkController = Material.of(context);
final RenderBox referenceBox = context.findRenderObject();
final RenderBox referenceBox = context.findRenderObject() as RenderBox;
final Offset position = referenceBox.globalToLocal(globalPosition);
final Color color = widget.splashColor ?? Theme.of(context).splashColor;
final RectCallback rectCallback = widget.containedInkWell ? widget.getRectCallback(referenceBox) : null;
......@@ -681,7 +681,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> with AutomaticKe
Offset globalPosition;
if (context != null) {
final RenderBox referenceBox = context.findRenderObject();
final RenderBox referenceBox = context.findRenderObject() as RenderBox;
assert(referenceBox.hasSize, 'InkResponse must be done with layout before starting a splash.');
globalPosition = referenceBox.localToGlobal(referenceBox.paintBounds.center);
} else {
......
......@@ -240,8 +240,8 @@ class UnderlineInputBorder extends InputBorder {
return true;
if (runtimeType != other.runtimeType)
return false;
final InputBorder typedOther = other;
return typedOther.borderSide == borderSide;
return other is InputBorder
&& other.borderSide == borderSide;
}
@override
......@@ -497,10 +497,10 @@ class OutlineInputBorder extends InputBorder {
return true;
if (runtimeType != other.runtimeType)
return false;
final OutlineInputBorder typedOther = other;
return typedOther.borderSide == borderSide
&& typedOther.borderRadius == borderRadius
&& typedOther.gapPadding == gapPadding;
return other is OutlineInputBorder
&& other.borderSide == borderSide
&& other.borderRadius == borderRadius
&& other.gapPadding == gapPadding;
}
@override
......
......@@ -975,10 +975,10 @@ class _ListTileElement extends RenderObjectElement {
final Map<Element, _ListTileSlot> childToSlot = <Element, _ListTileSlot>{};
@override
_ListTile get widget => super.widget;
_ListTile get widget => super.widget as _ListTile;
@override
_RenderListTile get renderObject => super.renderObject;
_RenderListTile get renderObject => super.renderObject as _RenderListTile;
@override
void visitChildren(ElementVisitor visitor) {
......@@ -1039,7 +1039,7 @@ class _ListTileElement extends RenderObjectElement {
_updateChild(widget.trailing, _ListTileSlot.trailing);
}
void _updateRenderObject(RenderObject child, _ListTileSlot slot) {
void _updateRenderObject(RenderBox child, _ListTileSlot slot) {
switch (slot) {
case _ListTileSlot.leading:
renderObject.leading = child;
......@@ -1060,8 +1060,8 @@ class _ListTileElement extends RenderObjectElement {
void insertChildRenderObject(RenderObject child, dynamic slotValue) {
assert(child is RenderBox);
assert(slotValue is _ListTileSlot);
final _ListTileSlot slot = slotValue;
_updateRenderObject(child, slot);
final _ListTileSlot slot = slotValue as _ListTileSlot;
_updateRenderObject(child as RenderBox, slot);
assert(renderObject.childToSlot.keys.contains(child));
assert(renderObject.slotToChild.keys.contains(slot));
}
......@@ -1303,7 +1303,7 @@ class _RenderListTile extends RenderBox {
@override
double computeDistanceToActualBaseline(TextBaseline baseline) {
assert(title != null);
final BoxParentData parentData = title.parentData;
final BoxParentData parentData = title.parentData as BoxParentData;
return parentData.offset.dy + title.getDistanceToActualBaseline(baseline);
}
......@@ -1319,7 +1319,7 @@ class _RenderListTile extends RenderBox {
}
static void _positionBox(RenderBox box, Offset offset) {
final BoxParentData parentData = box.parentData;
final BoxParentData parentData = box.parentData as BoxParentData;
parentData.offset = offset;
}
......@@ -1463,7 +1463,7 @@ class _RenderListTile extends RenderBox {
void paint(PaintingContext context, Offset offset) {
void doPaint(RenderBox child) {
if (child != null) {
final BoxParentData parentData = child.parentData;
final BoxParentData parentData = child.parentData as BoxParentData;
context.paintChild(child, parentData.offset + offset);
}
}
......@@ -1480,7 +1480,7 @@ class _RenderListTile extends RenderBox {
bool hitTestChildren(BoxHitTestResult result, { @required Offset position }) {
assert(position != null);
for (RenderBox child in _children) {
final BoxParentData parentData = child.parentData;
final BoxParentData parentData = child.parentData as BoxParentData;
final bool isHit = result.addWithPaintOffset(
offset: parentData.offset,
position: position,
......
......@@ -358,7 +358,7 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
}
contents = NotificationListener<LayoutChangedNotification>(
onNotification: (LayoutChangedNotification notification) {
final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext.findRenderObject();
final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext.findRenderObject() as _RenderInkFeatures;
renderer._didChangeLayout();
return false;
},
......@@ -575,7 +575,7 @@ abstract class InkFeature {
this.onRemoved,
}) : assert(controller != null),
assert(referenceBox != null),
_controller = controller;
_controller = controller as _RenderInkFeatures;
/// The [MaterialInkController] associated with this [InkFeature].
///
......@@ -612,7 +612,7 @@ abstract class InkFeature {
final List<RenderObject> descendants = <RenderObject>[referenceBox];
RenderObject node = referenceBox;
while (node != _controller) {
node = node.parent;
node = node.parent as RenderObject;
assert(node != null);
descendants.add(node);
}
......@@ -734,9 +734,21 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_elevation = visitor(_elevation, widget.elevation, (dynamic value) => Tween<double>(begin: value));
_shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => ColorTween(begin: value));
_border = visitor(_border, widget.shape, (dynamic value) => ShapeBorderTween(begin: value));
_elevation = visitor(
_elevation,
widget.elevation,
(dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>;
_shadowColor = visitor(
_shadowColor,
widget.shadowColor,
(dynamic value) => ColorTween(begin: value as Color),
) as ColorTween;
_border = visitor(
_border,
widget.shape,
(dynamic value) => ShapeBorderTween(begin: value as ShapeBorder),
) as ShapeBorderTween;
}
@override
......
......@@ -164,9 +164,10 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
_children = List<MergeableMaterialItem>.from(widget.children);
for (int i = 0; i < _children.length; i += 1) {
if (_children[i] is MaterialGap) {
_initGap(_children[i]);
_animationTuples[_children[i].key].controller.value = 1.0; // Gaps are initially full-sized.
final MergeableMaterialItem child = _children[i];
if (child is MaterialGap) {
_initGap(child);
_animationTuples[child.key].controller.value = 1.0; // Gaps are initially full-sized.
}
}
assert(_debugGapsAreValid(_children));
......@@ -323,8 +324,9 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
double gapSizeSum = 0.0;
while (startOld < j) {
if (_children[startOld] is MaterialGap) {
final MaterialGap gap = _children[startOld];
final MergeableMaterialItem child = _children[startOld];
if (child is MaterialGap) {
final MaterialGap gap = child;
gapSizeSum += gap.size;
}
......@@ -364,21 +366,19 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
double gapSizeSum = 0.0;
for (int k = startNew; k < i; k += 1) {
if (newChildren[k] is MaterialGap) {
final MaterialGap gap = newChildren[k];
gapSizeSum += gap.size;
final MergeableMaterialItem newChild = newChildren[k];
if (newChild is MaterialGap) {
gapSizeSum += newChild.size;
}
}
// All gaps get proportional sizes of the original gap and they will
// animate to their actual size.
for (int k = startNew; k < i; k += 1) {
if (newChildren[k] is MaterialGap) {
final MaterialGap gap = newChildren[k];
_animationTuples[gap.key].gapStart = gapSize * gap.size /
gapSizeSum;
_animationTuples[gap.key].controller
final MergeableMaterialItem newChild = newChildren[k];
if (newChild is MaterialGap) {
_animationTuples[newChild.key].gapStart = gapSize * newChild.size / gapSizeSum;
_animationTuples[newChild.key].controller
..value = 0.0
..forward();
}
......@@ -387,11 +387,12 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
} else {
// Grow gaps.
for (int k = 0; k < newLength; k += 1) {
_insertChild(startOld + k, newChildren[startNew + k]);
final MergeableMaterialItem newChild = newChildren[startNew + k];
if (newChildren[startNew + k] is MaterialGap) {
final MaterialGap gap = newChildren[startNew + k];
_animationTuples[gap.key].controller.forward();
_insertChild(startOld + k, newChild);
if (newChild is MaterialGap) {
_animationTuples[newChild.key].controller.forward();
}
}
......@@ -404,9 +405,9 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
double gapSizeSum = 0.0;
while (startOld < j) {
if (_children[startOld] is MaterialGap) {
final MaterialGap gap = _children[startOld];
gapSizeSum += gap.size;
final MergeableMaterialItem child = _children[startOld];
if (child is MaterialGap) {
gapSizeSum += child.size;
}
_removeChild(startOld);
......@@ -428,7 +429,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
}
} else if (oldLength == 1) {
// Shrink gap.
final MaterialGap gap = _children[startOld];
final MaterialGap gap = _children[startOld] as MaterialGap;
_animationTuples[gap.key].gapStart = 0.0;
_animationTuples[gap.key].controller.reverse();
}
......@@ -498,7 +499,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
}
double _getGapSize(int index) {
final MaterialGap gap = _children[index];
final MaterialGap gap = _children[index] as MaterialGap;
return lerpDouble(
_animationTuples[gap.key].gapStart,
......@@ -548,7 +549,7 @@ class _MergeableMaterialState extends State<MergeableMaterial> with TickerProvid
),
);
} else {
final MaterialSlice slice = _children[i];
final MaterialSlice slice = _children[i] as MaterialSlice;
Widget child = slice.child;
if (widget.hasDividers) {
......@@ -631,10 +632,8 @@ class _MergeableMaterialSliceKey extends GlobalKey {
@override
bool operator ==(dynamic other) {
if (other is! _MergeableMaterialSliceKey)
return false;
final _MergeableMaterialSliceKey typedOther = other;
return value == typedOther.value;
return other is _MergeableMaterialSliceKey
&& other.value == value;
}
@override
......@@ -671,7 +670,7 @@ class _MergeableMaterialListBody extends ListBody {
@override
void updateRenderObject(BuildContext context, RenderListBody renderObject) {
final _RenderMergeableMaterialListBody materialRenderListBody = renderObject;
final _RenderMergeableMaterialListBody materialRenderListBody = renderObject as _RenderMergeableMaterialListBody;
materialRenderListBody
..axisDirection = _getDirection(context)
..boxShadows = boxShadows;
......@@ -705,7 +704,7 @@ class _RenderMergeableMaterialListBody extends RenderListBody {
int i = 0;
while (child != null) {
final ListBodyParentData childParentData = child.parentData;
final ListBodyParentData childParentData = child.parentData as ListBodyParentData;
final Rect rect = (childParentData.offset + offset) & child.size;
if (i % 2 == 0)
_paintShadows(context.canvas, rect);
......
......@@ -557,8 +557,9 @@ class _OutlineBorder extends ShapeBorder implements MaterialStateProperty<ShapeB
return true;
if (runtimeType != other.runtimeType)
return false;
final _OutlineBorder typedOther = other;
return side == typedOther.side && shape == typedOther.shape;
return other is _OutlineBorder
&& other.side == side
&& other.shape == shape;
}
@override
......
......@@ -534,10 +534,10 @@ class PageTransitionsTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final PageTransitionsTheme typedOther = other;
if (identical(builders, other.builders))
return true;
return listEquals<PageTransitionsBuilder>(_all(builders), _all(typedOther.builders));
return other is PageTransitionsTheme
&& listEquals<PageTransitionsBuilder>(_all(other.builders), _all(builders));
}
@override
......
......@@ -226,7 +226,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
@override
void initState() {
super.initState();
_firstRowIndex = PageStorage.of(context)?.readState(context) ?? widget.initialFirstRowIndex ?? 0;
_firstRowIndex = PageStorage.of(context)?.readState(context) as int ?? widget.initialFirstRowIndex ?? 0;
widget.source.addListener(_handleDataSourceChanged);
_handleDataSourceChanged();
}
......@@ -382,7 +382,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
alignment: AlignmentDirectional.centerEnd,
child: DropdownButtonHideUnderline(
child: DropdownButton<int>(
items: availableRowsPerPage,
items: availableRowsPerPage.cast<DropdownMenuItem<int>>(),
value: widget.rowsPerPage,
onChanged: widget.onRowsPerPageChanged,
style: footerTextStyle,
......
......@@ -159,7 +159,7 @@ class _RenderMenuItem extends RenderShiftedBox {
child.layout(constraints, parentUsesSize: true);
size = constraints.constrain(child.size);
}
final BoxParentData childParentData = child.parentData;
final BoxParentData childParentData = child.parentData as BoxParentData;
childParentData.offset = Offset.zero;
onLayout(size);
}
......@@ -490,7 +490,7 @@ class _PopupMenu<T> extends StatelessWidget {
for (int i = 0; i < route.items.length; i += 1) {
final double start = (i + 1) * unit;
final double end = (start + 1.5 * unit).clamp(0.0, 1.0);
final double end = (start + 1.5 * unit).clamp(0.0, 1.0) as double;
final CurvedAnimation opacity = CurvedAnimation(
parent: route.animation,
curve: Interval(start, end),
......@@ -591,7 +591,9 @@ class _PopupMenuRouteLayout extends SingleChildLayoutDelegate {
BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
// The menu can be at most the size of the overlay minus 8.0 pixels in each
// direction.
return BoxConstraints.loose(constraints.biggest - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0));
return BoxConstraints.loose(
constraints.biggest - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0) as Size,
);
}
@override
......@@ -677,7 +679,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
final RelativeRect position;
final List<PopupMenuEntry<T>> items;
final List<Size> itemSizes;
final dynamic initialValue;
final T initialValue;
final double elevation;
final ThemeData theme;
final String semanticLabel;
......@@ -1041,8 +1043,8 @@ class PopupMenuButton<T> extends StatefulWidget {
class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
void showButtonMenu() {
final PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
final RenderBox button = context.findRenderObject();
final RenderBox overlay = Overlay.of(context).context.findRenderObject();
final RenderBox button = context.findRenderObject() as RenderBox;
final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox;
final RelativeRect position = RelativeRect.fromRect(
Rect.fromPoints(
button.localToGlobal(widget.offset, ancestor: overlay),
......
......@@ -99,11 +99,11 @@ class PopupMenuThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final PopupMenuThemeData typedOther = other;
return typedOther.elevation == elevation
&& typedOther.color == color
&& typedOther.shape == shape
&& typedOther.textStyle == textStyle;
return other is PopupMenuThemeData
&& other.elevation == elevation
&& other.color == color
&& other.shape == shape
&& other.textStyle == textStyle;
}
@override
......
......@@ -181,7 +181,7 @@ class _LinearProgressIndicatorPainter extends CustomPainter {
}
if (value != null) {
drawBar(0.0, value.clamp(0.0, 1.0) * size.width);
drawBar(0.0, value.clamp(0.0, 1.0) * size.width as double);
} else {
final double x1 = size.width * line1Tail.transform(animationValue);
final double width1 = size.width * line1Head.transform(animationValue) - x1;
......@@ -331,7 +331,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter {
? _startAngle
: _startAngle + tailValue * 3 / 2 * math.pi + rotationValue * math.pi * 1.7 - stepValue * 0.8 * math.pi,
arcSweep = value != null
? value.clamp(0.0, 1.0) * _sweep
? (value.clamp(0.0, 1.0) as double) * _sweep
: math.max(headValue * 3 / 2 * math.pi - tailValue * 3 / 2 * math.pi, _epsilon);
final Color backgroundColor;
......@@ -646,7 +646,7 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState {
@override
Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) {
final double arrowheadScale = widget.value == null ? 0.0 : (widget.value * 2.0).clamp(0.0, 1.0);
final double arrowheadScale = widget.value == null ? 0.0 : ((widget.value * 2.0).clamp(0.0, 1.0) as double);
return widget._buildSemanticsWrapper(
context: context,
child: Container(
......
......@@ -993,7 +993,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
}
double _discretize(double value) {
double result = value.clamp(0.0, 1.0);
double result = value.clamp(0.0, 1.0) as double;
if (isDiscrete) {
result = (result * divisions).round() / divisions;
}
......@@ -1005,7 +1005,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
}
void _startInteraction(Offset globalPosition) {
final double tapValue = _getValueFromGlobalPosition(globalPosition).clamp(0.0, 1.0);
final double tapValue = _getValueFromGlobalPosition(globalPosition).clamp(0.0, 1.0) as double;
_lastThumbSelection = sliderTheme.thumbSelector(textDirection, values, tapValue, _thumbSize, size, 0);
if (_lastThumbSelection != null) {
......@@ -1408,10 +1408,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
}
double _increaseValue(double value) {
return (value + _semanticActionUnit).clamp(0.0, 1.0);
return (value + _semanticActionUnit).clamp(0.0, 1.0) as double;
}
double _decreaseValue(double value) {
return (value - _semanticActionUnit).clamp(0.0, 1.0);
return (value - _semanticActionUnit).clamp(0.0, 1.0) as double;
}
}
......@@ -304,7 +304,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
double newValue = _dragOffset / (containerExtent * _kDragContainerExtentPercentage);
if (_mode == _RefreshIndicatorMode.armed)
newValue = math.max(newValue, 1.0 / _kDragSizeFactorLimit);
_positionController.value = newValue.clamp(0.0, 1.0); // this triggers various rebuilds
_positionController.value = newValue.clamp(0.0, 1.0) as double; // this triggers various rebuilds
if (_mode == _RefreshIndicatorMode.drag && _valueColor.value.alpha == 0xFF)
_mode = _RefreshIndicatorMode.armed;
}
......
......@@ -317,9 +317,9 @@ class _BodyBoxConstraints extends BoxConstraints {
bool operator ==(dynamic other) {
if (super != other)
return false;
final _BodyBoxConstraints typedOther = other;
return bottomWidgetsHeight == typedOther.bottomWidgetsHeight
&& appBarHeight == typedOther.appBarHeight;
return other is _BodyBoxConstraints
&& other.bottomWidgetsHeight == bottomWidgetsHeight
&& other.appBarHeight == appBarHeight;
}
@override
......@@ -356,7 +356,7 @@ class _BodyBuilder extends StatelessWidget {
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
final _BodyBoxConstraints bodyConstraints = constraints;
final _BodyBoxConstraints bodyConstraints = constraints as _BodyBoxConstraints;
final MediaQueryData metrics = MediaQuery.of(context);
final double bottom = extendBody
......@@ -741,10 +741,8 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
}
bool _isExtendedFloatingActionButton(Widget widget) {
if (widget is! FloatingActionButton)
return false;
final FloatingActionButton fab = widget;
return fab.isExtended;
return widget is FloatingActionButton
&& widget.isExtended;
}
@override
......@@ -1897,7 +1895,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
clipBehavior: clipBehavior,
);
});
return _currentBottomSheet;
return _currentBottomSheet as PersistentBottomSheetController<T>;
}
// Floating Action Button API
......@@ -1919,7 +1917,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
_floatingActionButtonVisibilityController.value = newValue.clamp(
_floatingActionButtonVisibilityController.lowerBound,
_floatingActionButtonVisibilityController.upperBound,
);
) as double;
}
/// Shows the [Scaffold.floatingActionButton].
......
......@@ -962,7 +962,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
}
double _discretize(double value) {
double result = value.clamp(0.0, 1.0);
double result = value.clamp(0.0, 1.0) as double;
if (isDiscrete) {
result = (result * divisions).round() / divisions;
}
......@@ -1191,8 +1191,8 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
config.onDecrease = _decreaseAction;
if (semanticFormatterCallback != null) {
config.value = semanticFormatterCallback(_state._lerp(value));
config.increasedValue = semanticFormatterCallback(_state._lerp((value + _semanticActionUnit).clamp(0.0, 1.0)));
config.decreasedValue = semanticFormatterCallback(_state._lerp((value - _semanticActionUnit).clamp(0.0, 1.0)));
config.increasedValue = semanticFormatterCallback(_state._lerp((value + _semanticActionUnit).clamp(0.0, 1.0) as double));
config.decreasedValue = semanticFormatterCallback(_state._lerp((value - _semanticActionUnit).clamp(0.0, 1.0) as double));
} else {
config.value = '${(value * 100).round()}%';
config.increasedValue = '${((value + _semanticActionUnit).clamp(0.0, 1.0) * 100).round()}%';
......@@ -1205,13 +1205,13 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
void _increaseAction() {
if (isInteractive) {
onChanged((value + _semanticActionUnit).clamp(0.0, 1.0));
onChanged((value + _semanticActionUnit).clamp(0.0, 1.0) as double);
}
}
void _decreaseAction() {
if (isInteractive) {
onChanged((value - _semanticActionUnit).clamp(0.0, 1.0));
onChanged((value - _semanticActionUnit).clamp(0.0, 1.0) as double);
}
}
}
......@@ -780,34 +780,34 @@ class SliderThemeData extends Diagnosticable {
if (other.runtimeType != runtimeType) {
return false;
}
final SliderThemeData otherData = other;
return otherData.trackHeight == trackHeight
&& otherData.activeTrackColor == activeTrackColor
&& otherData.inactiveTrackColor == inactiveTrackColor
&& otherData.disabledActiveTrackColor == disabledActiveTrackColor
&& otherData.disabledInactiveTrackColor == disabledInactiveTrackColor
&& otherData.activeTickMarkColor == activeTickMarkColor
&& otherData.inactiveTickMarkColor == inactiveTickMarkColor
&& otherData.disabledActiveTickMarkColor == disabledActiveTickMarkColor
&& otherData.disabledInactiveTickMarkColor == disabledInactiveTickMarkColor
&& otherData.thumbColor == thumbColor
&& otherData.overlappingShapeStrokeColor == overlappingShapeStrokeColor
&& otherData.disabledThumbColor == disabledThumbColor
&& otherData.overlayColor == overlayColor
&& otherData.valueIndicatorColor == valueIndicatorColor
&& otherData.overlayShape == overlayShape
&& otherData.tickMarkShape == tickMarkShape
&& otherData.thumbShape == thumbShape
&& otherData.trackShape == trackShape
&& otherData.valueIndicatorShape == valueIndicatorShape
&& otherData.rangeTickMarkShape == rangeTickMarkShape
&& otherData.rangeThumbShape == rangeThumbShape
&& otherData.rangeTrackShape == rangeTrackShape
&& otherData.rangeValueIndicatorShape == rangeValueIndicatorShape
&& otherData.showValueIndicator == showValueIndicator
&& otherData.valueIndicatorTextStyle == valueIndicatorTextStyle
&& otherData.minThumbSeparation == minThumbSeparation
&& otherData.thumbSelector == thumbSelector;
return other is SliderThemeData
&& other.trackHeight == trackHeight
&& other.activeTrackColor == activeTrackColor
&& other.inactiveTrackColor == inactiveTrackColor
&& other.disabledActiveTrackColor == disabledActiveTrackColor
&& other.disabledInactiveTrackColor == disabledInactiveTrackColor
&& other.activeTickMarkColor == activeTickMarkColor
&& other.inactiveTickMarkColor == inactiveTickMarkColor
&& other.disabledActiveTickMarkColor == disabledActiveTickMarkColor
&& other.disabledInactiveTickMarkColor == disabledInactiveTickMarkColor
&& other.thumbColor == thumbColor
&& other.overlappingShapeStrokeColor == overlappingShapeStrokeColor
&& other.disabledThumbColor == disabledThumbColor
&& other.overlayColor == overlayColor
&& other.valueIndicatorColor == valueIndicatorColor
&& other.overlayShape == overlayShape
&& other.tickMarkShape == tickMarkShape
&& other.thumbShape == thumbShape
&& other.trackShape == trackShape
&& other.valueIndicatorShape == valueIndicatorShape
&& other.rangeTickMarkShape == rangeTickMarkShape
&& other.rangeThumbShape == rangeThumbShape
&& other.rangeTrackShape == rangeTrackShape
&& other.rangeValueIndicatorShape == rangeValueIndicatorShape
&& other.showValueIndicator == showValueIndicator
&& other.valueIndicatorTextStyle == valueIndicatorTextStyle
&& other.minThumbSeparation == minThumbSeparation
&& other.thumbSelector == thumbSelector;
}
@override
......@@ -2768,8 +2768,8 @@ class _PaddleSliderTrackShapePathPainter {
// the top neck arc. We use this to shrink/expand it based on the scale
// factor of the value indicator.
final double neckStretchBaseline = math.max(0.0, rightBottomNeckCenterY - math.max(leftTopNeckCenter.dy, neckRightCenter.dy));
final double t = math.pow(inverseTextScale, 3.0);
final double stretch = (neckStretchBaseline * t).clamp(0.0, 10.0 * neckStretchBaseline);
final double t = math.pow(inverseTextScale, 3.0) as double;
final double stretch = (neckStretchBaseline * t).clamp(0.0, 10.0 * neckStretchBaseline) as double;
final Offset neckStretch = Offset(0.0, neckStretchBaseline - stretch);
assert(!_debuggingLabelLocation || () {
......@@ -2886,9 +2886,9 @@ class RangeValues {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType)
return false;
final RangeValues typedOther = other;
return typedOther.start == start
&& typedOther.end == end;
return other is RangeValues
&& other.start == start
&& other.end == end;
}
@override
......@@ -2925,9 +2925,9 @@ class RangeLabels {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType)
return false;
final RangeLabels typedOther = other;
return typedOther.start == start
&& typedOther.end == end;
return other is RangeLabels
&& other.start == start
&& other.end == end;
}
@override
......
......@@ -161,14 +161,14 @@ class SnackBarThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final SnackBarThemeData typedOther = other;
return typedOther.backgroundColor == backgroundColor
&& typedOther.actionTextColor == actionTextColor
&& typedOther.disabledActionTextColor == disabledActionTextColor
&& typedOther.contentTextStyle == contentTextStyle
&& typedOther.elevation == elevation
&& typedOther.shape == shape
&& typedOther.behavior == behavior;
return other is SnackBarThemeData
&& other.backgroundColor == backgroundColor
&& other.actionTextColor == actionTextColor
&& other.disabledActionTextColor == disabledActionTextColor
&& other.contentTextStyle == contentTextStyle
&& other.elevation == elevation
&& other.shape == shape
&& other.behavior == behavior;
}
@override
......
......@@ -96,7 +96,7 @@ class TabBarTheme extends Diagnosticable {
indicator: Decoration.lerp(a.indicator, b.indicator, t),
indicatorSize: t < 0.5 ? a.indicatorSize : b.indicatorSize,
labelColor: Color.lerp(a.labelColor, b.labelColor, t),
labelPadding: EdgeInsets.lerp(a.labelPadding, b.labelPadding, t),
labelPadding: EdgeInsetsGeometry.lerp(a.labelPadding, b.labelPadding, t),
labelStyle: TextStyle.lerp(a.labelStyle, b.labelStyle, t),
unselectedLabelColor: Color.lerp(a.unselectedLabelColor, b.unselectedLabelColor, t),
unselectedLabelStyle: TextStyle.lerp(a.unselectedLabelStyle, b.unselectedLabelStyle, t),
......@@ -122,13 +122,13 @@ class TabBarTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final TabBarTheme typedOther = other;
return typedOther.indicator == indicator
&& typedOther.indicatorSize == indicatorSize
&& typedOther.labelColor == labelColor
&& typedOther.labelPadding == labelPadding
&& typedOther.labelStyle == labelStyle
&& typedOther.unselectedLabelColor == unselectedLabelColor
&& typedOther.unselectedLabelStyle == unselectedLabelStyle;
return other is TabBarTheme
&& other.indicator == indicator
&& other.indicatorSize == indicatorSize
&& other.labelColor == labelColor
&& other.labelPadding == labelPadding
&& other.labelStyle == labelStyle
&& other.unselectedLabelColor == unselectedLabelColor
&& other.unselectedLabelStyle == unselectedLabelStyle;
}
}
......@@ -156,7 +156,7 @@ class _TabStyle extends AnimatedWidget {
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
final TabBarTheme tabBarTheme = TabBarTheme.of(context);
final Animation<double> animation = listenable;
final Animation<double> animation = listenable as Animation<double>;
// To enable TextStyle.lerp(style1, style2, value), both styles must have
// the same value of inherit. Force that to be inherit=true here.
......@@ -232,7 +232,7 @@ class _TabLabelBarRenderer extends RenderFlex {
RenderBox child = firstChild;
final List<double> xOffsets = <double>[];
while (child != null) {
final FlexParentData childParentData = child.parentData;
final FlexParentData childParentData = child.parentData as FlexParentData;
xOffsets.add(childParentData.offset.dx);
assert(child.parentData == childParentData);
child = childParentData.nextSibling;
......@@ -298,7 +298,7 @@ double _indexChangeProgress(TabController controller) {
// The controller's offset is changing because the user is dragging the
// TabBarView's PageView to the left or right.
if (!controller.indexIsChanging)
return (currentIndex - controllerValue).abs().clamp(0.0, 1.0);
return (currentIndex - controllerValue).abs().clamp(0.0, 1.0) as double;
// The TabController animation's value is changing from previousIndex to currentIndex.
return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs();
......@@ -489,7 +489,7 @@ class _DragAnimation extends Animation<double> with AnimationWithParentMixin<dou
@override
double get value {
assert(!controller.indexIsChanging);
return (controller.animation.value - index.toDouble()).abs().clamp(0.0, 1.0);
return (controller.animation.value - index.toDouble()).abs().clamp(0.0, 1.0) as double;
}
}
......@@ -900,7 +900,7 @@ class _TabBarState extends State<TabBar> {
case TextDirection.ltr:
break;
}
return (tabCenter - viewportWidth / 2.0).clamp(minExtent, maxExtent);
return (tabCenter - viewportWidth / 2.0).clamp(minExtent, maxExtent) as double;
}
double _tabCenteredScrollOffset(int index) {
......@@ -1302,7 +1302,7 @@ class _TabBarViewState extends State<TabBarView> {
_controller.index = _pageController.page.floor();
_currentIndex =_controller.index;
}
_controller.offset = (_pageController.page - _controller.index).clamp(-1.0, 1.0);
_controller.offset = (_pageController.page - _controller.index).clamp(-1.0, 1.0) as double;
} else if (notification is ScrollEndNotification) {
_controller.index = _pageController.page.round();
_currentIndex = _controller.index;
......
......@@ -782,7 +782,7 @@ class _TextFieldState extends State<TextField> implements TextSelectionGestureDe
if (widget.maxLength > 0) {
// Show the maxLength in the counter
counterText += '/${widget.maxLength}';
final int remaining = (widget.maxLength - currentLength).clamp(0, widget.maxLength);
final int remaining = (widget.maxLength - currentLength).clamp(0, widget.maxLength) as int;
semanticCounterText = localizations.remainingTextFieldCharacterCount(remaining);
// Handle length exceeds maxLength
......
......@@ -152,7 +152,7 @@ class TextFormField extends FormField<String> {
autovalidate: autovalidate,
enabled: enabled,
builder: (FormFieldState<String> field) {
final _TextFormFieldState state = field;
final _TextFormFieldState state = field as _TextFormFieldState;
final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration())
.applyDefaults(Theme.of(field.context).inputDecorationTheme);
void onChangedHandler(String value) {
......@@ -218,7 +218,7 @@ class _TextFormFieldState extends FormFieldState<String> {
TextEditingController get _effectiveController => widget.controller ?? _controller;
@override
TextFormField get widget => super.widget;
TextFormField get widget => super.widget as TextFormField;
@override
void initState() {
......
......@@ -481,20 +481,20 @@ class TextTheme extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final TextTheme typedOther = other;
return display4 == typedOther.display4
&& display3 == typedOther.display3
&& display2 == typedOther.display2
&& display1 == typedOther.display1
&& headline == typedOther.headline
&& title == typedOther.title
&& subhead == typedOther.subhead
&& body2 == typedOther.body2
&& body1 == typedOther.body1
&& caption == typedOther.caption
&& button == typedOther.button
&& subtitle == typedOther.subtitle
&& overline == typedOther.overline;
return other is TextTheme
&& other.display4 == display4
&& other.display3 == display3
&& other.display2 == display2
&& other.display1 == display1
&& other.headline == headline
&& other.title == title
&& other.subhead == subhead
&& other.body2 == body2
&& other.body1 == body1
&& other.caption == caption
&& other.button == button
&& other.subtitle == subtitle
&& other.overline == overline;
}
@override
......
......@@ -254,7 +254,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
// TODO(ianh): Use constructor tear-offs when it becomes possible
_data = visitor(_data, widget.data, (dynamic value) => ThemeDataTween(begin: value));
_data = visitor(_data, widget.data, (dynamic value) => ThemeDataTween(begin: value as ThemeData)) as ThemeDataTween;
assert(_data != null);
}
......
......@@ -1297,71 +1297,71 @@ class ThemeData extends Diagnosticable {
bool operator ==(Object other) {
if (other.runtimeType != runtimeType)
return false;
final ThemeData otherData = other;
// Warning: make sure these properties are in the exact same order as in
// hashValues() and in the raw constructor and in the order of fields in
// the class and in the lerp() method.
return (otherData.brightness == brightness) &&
(otherData.visualDensity == visualDensity) &&
(otherData.primaryColor == primaryColor) &&
(otherData.primaryColorBrightness == primaryColorBrightness) &&
(otherData.primaryColorLight == primaryColorLight) &&
(otherData.primaryColorDark == primaryColorDark) &&
(otherData.accentColor == accentColor) &&
(otherData.accentColorBrightness == accentColorBrightness) &&
(otherData.canvasColor == canvasColor) &&
(otherData.scaffoldBackgroundColor == scaffoldBackgroundColor) &&
(otherData.bottomAppBarColor == bottomAppBarColor) &&
(otherData.cardColor == cardColor) &&
(otherData.dividerColor == dividerColor) &&
(otherData.highlightColor == highlightColor) &&
(otherData.splashColor == splashColor) &&
(otherData.splashFactory == splashFactory) &&
(otherData.selectedRowColor == selectedRowColor) &&
(otherData.unselectedWidgetColor == unselectedWidgetColor) &&
(otherData.disabledColor == disabledColor) &&
(otherData.buttonTheme == buttonTheme) &&
(otherData.buttonColor == buttonColor) &&
(otherData.toggleButtonsTheme == toggleButtonsTheme) &&
(otherData.secondaryHeaderColor == secondaryHeaderColor) &&
(otherData.textSelectionColor == textSelectionColor) &&
(otherData.cursorColor == cursorColor) &&
(otherData.textSelectionHandleColor == textSelectionHandleColor) &&
(otherData.backgroundColor == backgroundColor) &&
(otherData.dialogBackgroundColor == dialogBackgroundColor) &&
(otherData.indicatorColor == indicatorColor) &&
(otherData.hintColor == hintColor) &&
(otherData.errorColor == errorColor) &&
(otherData.toggleableActiveColor == toggleableActiveColor) &&
(otherData.textTheme == textTheme) &&
(otherData.primaryTextTheme == primaryTextTheme) &&
(otherData.accentTextTheme == accentTextTheme) &&
(otherData.inputDecorationTheme == inputDecorationTheme) &&
(otherData.iconTheme == iconTheme) &&
(otherData.primaryIconTheme == primaryIconTheme) &&
(otherData.accentIconTheme == accentIconTheme) &&
(otherData.sliderTheme == sliderTheme) &&
(otherData.tabBarTheme == tabBarTheme) &&
(otherData.tooltipTheme == tooltipTheme) &&
(otherData.cardTheme == cardTheme) &&
(otherData.chipTheme == chipTheme) &&
(otherData.platform == platform) &&
(otherData.materialTapTargetSize == materialTapTargetSize) &&
(otherData.applyElevationOverlayColor == applyElevationOverlayColor) &&
(otherData.pageTransitionsTheme == pageTransitionsTheme) &&
(otherData.appBarTheme == appBarTheme) &&
(otherData.bottomAppBarTheme == bottomAppBarTheme) &&
(otherData.colorScheme == colorScheme) &&
(otherData.dialogTheme == dialogTheme) &&
(otherData.floatingActionButtonTheme == floatingActionButtonTheme) &&
(otherData.typography == typography) &&
(otherData.cupertinoOverrideTheme == cupertinoOverrideTheme) &&
(otherData.snackBarTheme == snackBarTheme) &&
(otherData.bottomSheetTheme == bottomSheetTheme) &&
(otherData.popupMenuTheme == popupMenuTheme) &&
(otherData.bannerTheme == bannerTheme) &&
(otherData.dividerTheme == dividerTheme) &&
(otherData.buttonBarTheme == buttonBarTheme);
return other is ThemeData
&& other.brightness == brightness
&& other.visualDensity == visualDensity
&& other.primaryColor == primaryColor
&& other.primaryColorBrightness == primaryColorBrightness
&& other.primaryColorLight == primaryColorLight
&& other.primaryColorDark == primaryColorDark
&& other.accentColor == accentColor
&& other.accentColorBrightness == accentColorBrightness
&& other.canvasColor == canvasColor
&& other.scaffoldBackgroundColor == scaffoldBackgroundColor
&& other.bottomAppBarColor == bottomAppBarColor
&& other.cardColor == cardColor
&& other.dividerColor == dividerColor
&& other.highlightColor == highlightColor
&& other.splashColor == splashColor
&& other.splashFactory == splashFactory
&& other.selectedRowColor == selectedRowColor
&& other.unselectedWidgetColor == unselectedWidgetColor
&& other.disabledColor == disabledColor
&& other.buttonTheme == buttonTheme
&& other.buttonColor == buttonColor
&& other.toggleButtonsTheme == toggleButtonsTheme
&& other.secondaryHeaderColor == secondaryHeaderColor
&& other.textSelectionColor == textSelectionColor
&& other.cursorColor == cursorColor
&& other.textSelectionHandleColor == textSelectionHandleColor
&& other.backgroundColor == backgroundColor
&& other.dialogBackgroundColor == dialogBackgroundColor
&& other.indicatorColor == indicatorColor
&& other.hintColor == hintColor
&& other.errorColor == errorColor
&& other.toggleableActiveColor == toggleableActiveColor
&& other.textTheme == textTheme
&& other.primaryTextTheme == primaryTextTheme
&& other.accentTextTheme == accentTextTheme
&& other.inputDecorationTheme == inputDecorationTheme
&& other.iconTheme == iconTheme
&& other.primaryIconTheme == primaryIconTheme
&& other.accentIconTheme == accentIconTheme
&& other.sliderTheme == sliderTheme
&& other.tabBarTheme == tabBarTheme
&& other.tooltipTheme == tooltipTheme
&& other.cardTheme == cardTheme
&& other.chipTheme == chipTheme
&& other.platform == platform
&& other.materialTapTargetSize == materialTapTargetSize
&& other.applyElevationOverlayColor == applyElevationOverlayColor
&& other.pageTransitionsTheme == pageTransitionsTheme
&& other.appBarTheme == appBarTheme
&& other.bottomAppBarTheme == bottomAppBarTheme
&& other.colorScheme == colorScheme
&& other.dialogTheme == dialogTheme
&& other.floatingActionButtonTheme == floatingActionButtonTheme
&& other.typography == typography
&& other.cupertinoOverrideTheme == cupertinoOverrideTheme
&& other.snackBarTheme == snackBarTheme
&& other.bottomSheetTheme == bottomSheetTheme
&& other.popupMenuTheme == popupMenuTheme
&& other.bannerTheme == bannerTheme
&& other.dividerTheme == dividerTheme
&& other.buttonBarTheme == buttonBarTheme;
}
@override
......@@ -1636,8 +1636,9 @@ class _IdentityThemeDataCacheKey {
bool operator ==(Object other) {
// We are explicitly ignoring the possibility that the types might not
// match in the interests of speed.
final _IdentityThemeDataCacheKey otherKey = other;
return identical(baseTheme, otherKey.baseTheme) && identical(localTextGeometry, otherKey.localTextGeometry);
return other is _IdentityThemeDataCacheKey
&& identical(other.baseTheme, baseTheme)
&& identical(other.localTextGeometry, localTextGeometry);
}
}
......@@ -1819,9 +1820,9 @@ class VisualDensity extends Diagnosticable {
if (other.runtimeType != runtimeType) {
return false;
}
final VisualDensity typedOther = other;
return horizontal == typedOther.horizontal
&& vertical == typedOther.vertical;
return other is VisualDensity
&& other.horizontal == horizontal
&& other.vertical == vertical;
}
@override
......
......@@ -113,11 +113,9 @@ class TimeOfDay {
@override
bool operator ==(dynamic other) {
if (other is! TimeOfDay)
return false;
final TimeOfDay typedOther = other;
return typedOther.hour == hour
&& typedOther.minute == minute;
return other is TimeOfDay
&& other.hour == hour
&& other.minute == minute;
}
@override
......
......@@ -1004,7 +1004,7 @@ class _DialPainter extends CustomPainter {
final double width = labelPainter.width * _semanticNodeSizeScale;
final double height = labelPainter.height * _semanticNodeSizeScale;
final Offset nodeOffset = getOffsetForTheta(labelTheta, ring) + Offset(-width / 2.0, -height / 2.0);
final TextSpan textSpan = labelPainter.text;
final TextSpan textSpan = labelPainter.text as TextSpan;
final CustomPainterSemantics node = CustomPainterSemantics(
rect: Rect.fromLTRB(
nodeOffset.dx - 24.0 + width / 2,
......@@ -1190,7 +1190,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
_thetaTween
..begin = angle
..end = angle; // The controller doesn't animate during the pan gesture.
final RenderBox box = context.findRenderObject();
final RenderBox box = context.findRenderObject() as RenderBox;
final double radius = box.size.shortestSide / 2.0;
if (widget.mode == _TimePickerMode.hour && widget.use24HourDials) {
if (offset.distance * 1.5 < radius)
......@@ -1208,7 +1208,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
void _handlePanStart(DragStartDetails details) {
assert(!_dragging);
_dragging = true;
final RenderBox box = context.findRenderObject();
final RenderBox box = context.findRenderObject() as RenderBox;
_position = box.globalToLocal(details.globalPosition);
_center = box.size.center(Offset.zero);
_updateThetaForPan();
......@@ -1235,7 +1235,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
}
void _handleTapUp(TapUpDetails details) {
final RenderBox box = context.findRenderObject();
final RenderBox box = context.findRenderObject() as RenderBox;
_position = box.globalToLocal(details.globalPosition);
_center = box.size.center(Offset.zero);
_updateThetaForPan();
......
......@@ -1061,7 +1061,7 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox {
);
child.layout(innerConstraints, parentUsesSize: true);
final BoxParentData childParentData = child.parentData;
final BoxParentData childParentData = child.parentData as BoxParentData;
childParentData.offset = Offset(leadingBorderSide.width, leadingBorderSide.width);
size = constraints.constrain(Size(
......@@ -1083,7 +1083,7 @@ class _SelectToggleButtonRenderObject extends RenderShiftedBox {
);
child.layout(innerConstraints, parentUsesSize: true);
final BoxParentData childParentData = child.parentData;
final BoxParentData childParentData = child.parentData as BoxParentData;
if (isLastButton) {
childParentData.offset = Offset(trailingBorderOffset, trailingBorderOffset);
......
......@@ -195,22 +195,22 @@ class ToggleButtonsThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final ToggleButtonsThemeData typedOther = other;
return typedOther.textStyle == textStyle
&& typedOther.constraints == constraints
&& typedOther.color == color
&& typedOther.selectedColor == selectedColor
&& typedOther.disabledColor == disabledColor
&& typedOther.fillColor == fillColor
&& typedOther.focusColor == focusColor
&& typedOther.highlightColor == highlightColor
&& typedOther.hoverColor == hoverColor
&& typedOther.splashColor == splashColor
&& typedOther.borderColor == borderColor
&& typedOther.selectedBorderColor == selectedBorderColor
&& typedOther.disabledBorderColor == disabledBorderColor
&& typedOther.borderRadius == borderRadius
&& typedOther.borderWidth == borderWidth;
return other is ToggleButtonsThemeData
&& other.textStyle == textStyle
&& other.constraints == constraints
&& other.color == color
&& other.selectedColor == selectedColor
&& other.disabledColor == disabledColor
&& other.fillColor == fillColor
&& other.focusColor == focusColor
&& other.highlightColor == highlightColor
&& other.hoverColor == hoverColor
&& other.splashColor == splashColor
&& other.borderColor == borderColor
&& other.selectedBorderColor == selectedBorderColor
&& other.disabledBorderColor == disabledBorderColor
&& other.borderRadius == borderRadius
&& other.borderWidth == borderWidth;
}
@override
......
......@@ -280,7 +280,7 @@ class _TooltipState extends State<Tooltip> with SingleTickerProviderStateMixin {
}
void _createNewEntry() {
final RenderBox box = context.findRenderObject();
final RenderBox box = context.findRenderObject() as RenderBox;
final Offset target = box.localToGlobal(box.size.center(Offset.zero));
// We create this widget outside of the overlay entry's builder to prevent
......
......@@ -122,8 +122,8 @@ class TooltipThemeData extends Diagnosticable {
assert(t != null);
return TooltipThemeData(
height: lerpDouble(a?.height, b?.height, t),
padding: EdgeInsets.lerp(a?.padding, b?.padding, t),
margin: EdgeInsets.lerp(a?.margin, b?.margin, t),
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
margin: EdgeInsetsGeometry.lerp(a?.margin, b?.margin, t),
verticalOffset: lerpDouble(a?.verticalOffset, b?.verticalOffset, t),
preferBelow: t < 0.5 ? a.preferBelow: b.preferBelow,
excludeFromSemantics: t < 0.5 ? a.excludeFromSemantics : b.excludeFromSemantics,
......@@ -154,17 +154,17 @@ class TooltipThemeData extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final TooltipThemeData typedOther = other;
return typedOther.height == height
&& typedOther.padding == padding
&& typedOther.margin == margin
&& typedOther.verticalOffset == verticalOffset
&& typedOther.preferBelow == preferBelow
&& typedOther.excludeFromSemantics == excludeFromSemantics
&& typedOther.decoration == decoration
&& typedOther.textStyle == textStyle
&& typedOther.waitDuration == waitDuration
&& typedOther.showDuration == showDuration;
return other is TooltipThemeData
&& other.height == height
&& other.padding == padding
&& other.margin == margin
&& other.verticalOffset == verticalOffset
&& other.preferBelow == preferBelow
&& other.excludeFromSemantics == excludeFromSemantics
&& other.decoration == decoration
&& other.textStyle == textStyle
&& other.waitDuration == waitDuration
&& other.showDuration == showDuration;
}
@override
......
......@@ -234,12 +234,12 @@ class Typography extends Diagnosticable {
return true;
if (other.runtimeType != runtimeType)
return false;
final Typography otherTypography = other;
return otherTypography.black == black
&& otherTypography.white == white
&& otherTypography.englishLike == englishLike
&& otherTypography.dense == dense
&& otherTypography.tall == tall;
return other is Typography
&& other.black == black
&& other.white == white
&& other.englishLike == englishLike
&& other.dense == dense
&& other.tall == tall;
}
@override
......
......@@ -232,7 +232,7 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate {
final String bottomLine = hasChild(accountEmail) ? accountEmail : (hasChild(accountName) ? accountName : null);
if (bottomLine != null) {
final Size constraintSize = iconSize == null ? size : size - Offset(iconSize.width, 0.0);
final Size constraintSize = iconSize == null ? size : Size(size.width - iconSize.width, size.height);
iconSize ??= const Size(_kAccountDetailsHeight, _kAccountDetailsHeight);
// place bottom line center at same height as icon center
......
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