diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index 1a83b866c7..6ad3026e56 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -215,7 +215,7 @@ class Actions extends InheritedWidget { // doesn't find one. static ActionDispatcher _findDispatcher(Element element) { assert(element.widget is Actions); - final Actions actions = element.widget; + final Actions actions = element.widget as Actions; ActionDispatcher dispatcher = actions.dispatcher; if (dispatcher == null) { bool visitAncestorElement(Element visitedElement) { @@ -223,7 +223,7 @@ class Actions extends InheritedWidget { // Continue visiting. return true; } - final Actions actions = visitedElement.widget; + final Actions actions = visitedElement.widget as Actions; if (actions.dispatcher == null) { // Continue visiting. return true; @@ -250,7 +250,7 @@ class Actions extends InheritedWidget { static ActionDispatcher of(BuildContext context, {bool nullOk = false}) { assert(context != null); final InheritedElement inheritedElement = context.getElementForInheritedWidgetOfExactType(); - final Actions inherited = context.dependOnInheritedElement(inheritedElement); + final Actions inherited = context.dependOnInheritedElement(inheritedElement) as Actions; assert(() { if (nullOk) { return true; @@ -306,7 +306,7 @@ class Actions extends InheritedWidget { // Below when we invoke the action, we need to use the dispatcher from the // Actions widget where we found the action, in case they need to match. actionsElement = element; - final Actions actions = element.widget; + final Actions actions = element.widget as Actions; action = actions.actions[intent.key]?.call(); // Keep looking if we failed to find and create an action. return action == null; diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index ad0898d7bf..b5554ce89f 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -268,12 +268,10 @@ class AsyncSnapshot { bool operator ==(dynamic other) { if (identical(this, other)) return true; - if (other is! AsyncSnapshot) - return false; - final AsyncSnapshot typedOther = other; - return connectionState == typedOther.connectionState - && data == typedOther.data - && error == typedOther.error; + return other is AsyncSnapshot + && other.connectionState == connectionState + && other.data == data + && other.error == error; } @override diff --git a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart index ba61134978..aafc4417d0 100644 --- a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart +++ b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart @@ -107,7 +107,7 @@ class _AutomaticKeepAliveState extends State { /// the first build of that child has not completed yet. ParentDataElement _getChildElement() { assert(mounted); - final Element element = context; + final Element element = context as Element; Element childElement; // We use Element.visitChildren rather than context.visitChildElements // because we might be called during build, and context.visitChildElements @@ -132,11 +132,11 @@ class _AutomaticKeepAliveState extends State { childElement = child; }); assert(childElement == null || childElement is ParentDataElement); - return childElement; + return childElement as ParentDataElement; } void _updateParentDataOfChild(ParentDataElement childElement) { - childElement.applyWidgetOutOfTurn(build(context)); + childElement.applyWidgetOutOfTurn(build(context) as ParentDataWidget); } VoidCallback _createCallback(Listenable handle) { diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index f6cfdf2335..f23b57ea13 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1931,7 +1931,7 @@ class LayoutId extends ParentDataWidget { @override void applyParentData(RenderObject renderObject) { assert(renderObject.parentData is MultiChildLayoutParentData); - final MultiChildLayoutParentData parentData = renderObject.parentData; + final MultiChildLayoutParentData parentData = renderObject.parentData as MultiChildLayoutParentData; if (parentData.id != id) { parentData.id = id; final AbstractNode targetParent = renderObject.parent; @@ -2659,7 +2659,7 @@ class _OffstageElement extends SingleChildRenderObjectElement { _OffstageElement(Offstage widget) : super(widget); @override - Offstage get widget => super.widget; + Offstage get widget => super.widget as Offstage; @override void debugVisitOnstageChildren(ElementVisitor visitor) { @@ -3528,7 +3528,7 @@ class Positioned extends ParentDataWidget { @override void applyParentData(RenderObject renderObject) { assert(renderObject.parentData is StackParentData); - final StackParentData parentData = renderObject.parentData; + final StackParentData parentData = renderObject.parentData as StackParentData; bool needsLayout = false; if (parentData.left != left) { @@ -4384,7 +4384,7 @@ class Flexible extends ParentDataWidget { @override void applyParentData(RenderObject renderObject) { assert(renderObject.parentData is FlexParentData); - final FlexParentData parentData = renderObject.parentData; + final FlexParentData parentData = renderObject.parentData as FlexParentData; bool needsLayout = false; if (parentData.flex != flex) { @@ -5968,13 +5968,13 @@ class _MouseRegionElement extends SingleChildRenderObjectElement { @override void activate() { super.activate(); - final RenderMouseRegion renderMouseRegion = renderObject; + final RenderMouseRegion renderMouseRegion = renderObject as RenderMouseRegion; renderMouseRegion.postActivate(); } @override void deactivate() { - final RenderMouseRegion renderMouseRegion = renderObject; + final RenderMouseRegion renderMouseRegion = renderObject as RenderMouseRegion; renderMouseRegion.preDeactivate(); super.deactivate(); } @@ -6763,7 +6763,7 @@ class KeyedSubtree extends StatelessWidget { /// Wrap each item in a KeyedSubtree whose key is based on the item's existing key or /// the sum of its list index and `baseIndex`. - static List ensureUniqueKeysForList(Iterable items, { int baseIndex = 0 }) { + static List ensureUniqueKeysForList(List items, { int baseIndex = 0 }) { if (items == null || items.isEmpty) return items; diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 80f1b14ed9..15338a3633 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -535,7 +535,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB case 'popRoute': return handlePopRoute(); case 'pushRoute': - return handlePushRoute(methodCall.arguments); + return handlePushRoute(methodCall.arguments as String); } return Future.value(); } @@ -563,8 +563,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB @override Future handleSystemMessage(Object systemMessage) async { await super.handleSystemMessage(systemMessage); - final Map message = systemMessage; - final String type = message['type']; + final Map message = systemMessage as Map; + final String type = message['type'] as String; switch (type) { case 'memoryPressure': handleMemoryPressure(); @@ -821,7 +821,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB container: renderView, debugShortDescription: '[root]', child: rootWidget, - ).attachToRenderTree(buildOwner, renderViewElement); + ).attachToRenderTree(buildOwner, renderViewElement as RenderObjectToWidgetElement); } /// Whether the [renderViewElement] has been initialized. @@ -976,7 +976,7 @@ class RenderObjectToWidgetElement extends RootRenderObje RenderObjectToWidgetElement(RenderObjectToWidgetAdapter widget) : super(widget); @override - RenderObjectToWidgetAdapter get widget => super.widget; + RenderObjectToWidgetAdapter get widget => super.widget as RenderObjectToWidgetAdapter; Element _child; @@ -1019,7 +1019,7 @@ class RenderObjectToWidgetElement extends RootRenderObje // due to a reassemble. final Widget newWidget = _newWidget; _newWidget = null; - update(newWidget); + update(newWidget as RenderObjectToWidgetAdapter); } super.performRebuild(); assert(_newWidget == null); @@ -1043,13 +1043,13 @@ class RenderObjectToWidgetElement extends RootRenderObje } @override - RenderObjectWithChildMixin get renderObject => super.renderObject; + RenderObjectWithChildMixin get renderObject => super.renderObject as RenderObjectWithChildMixin; @override void insertChildRenderObject(RenderObject child, dynamic slot) { assert(slot == _rootChildSlot); assert(renderObject.debugValidateChild(child)); - renderObject.child = child; + renderObject.child = child as T; } @override diff --git a/packages/flutter/lib/src/widgets/color_filter.dart b/packages/flutter/lib/src/widgets/color_filter.dart index 81d32783f7..5b6ce657ef 100644 --- a/packages/flutter/lib/src/widgets/color_filter.dart +++ b/packages/flutter/lib/src/widgets/color_filter.dart @@ -55,6 +55,6 @@ class _ColorFilterRenderObject extends RenderProxyBox { @override void paint(PaintingContext context, Offset offset) { - layer = context.pushColorFilter(offset, colorFilter, super.paint, oldLayer: layer); + layer = context.pushColorFilter(offset, colorFilter, super.paint, oldLayer: layer as ColorFilterLayer); } } diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index d568c0f8f5..f504e9b08e 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -356,7 +356,7 @@ class _DraggableState extends State> { _recognizer = null; } - void _routePointer(PointerEvent event) { + void _routePointer(PointerDownEvent event) { if (widget.maxSimultaneousDrags != null && _activeCount >= widget.maxSimultaneousDrags) return; _recognizer.addPointer(event); @@ -368,7 +368,7 @@ class _DraggableState extends State> { Offset dragStartPoint; switch (widget.dragAnchor) { case DragAnchor.child: - final RenderBox renderObject = context.findRenderObject(); + final RenderBox renderObject = context.findRenderObject() as RenderBox; dragStartPoint = renderObject.globalToLocal(position); break; case DragAnchor.pointer: @@ -519,7 +519,8 @@ class _DragTargetState extends State> { bool didEnter(_DragAvatar avatar) { assert(!_candidateAvatars.contains(avatar)); assert(!_rejectedAvatars.contains(avatar)); - if (avatar.data is T && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) { + final dynamic data = avatar.data; + if (data is T && (widget.onWillAccept == null || widget.onWillAccept(data))) { setState(() { _candidateAvatars.add(avatar); }); @@ -670,10 +671,11 @@ class _DragAvatar extends Drag { // Look for the RenderBoxes that corresponds to the hit target (the hit target // widgets build RenderMetaData boxes for us for this purpose). for (HitTestEntry entry in path) { - if (entry.target is RenderMetaData) { - final RenderMetaData renderMetaData = entry.target; - if (renderMetaData.metaData is _DragTargetState) - yield renderMetaData.metaData; + final HitTestTarget target = entry.target; + if (target is RenderMetaData) { + final dynamic metaData = target.metaData; + if (metaData is _DragTargetState) + yield metaData; } } } @@ -701,7 +703,7 @@ class _DragAvatar extends Drag { } Widget _build(BuildContext context) { - final RenderBox box = overlayState.context.findRenderObject(); + final RenderBox box = overlayState.context.findRenderObject() as RenderBox; final Offset overlayTopLeft = box.localToGlobal(Offset.zero); return Positioned( left: _lastOffset.dx - overlayTopLeft.dx, diff --git a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart index d236f054c3..73d4222c6a 100644 --- a/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart +++ b/packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart @@ -260,7 +260,7 @@ class _DraggableSheetExtent { set currentExtent(double value) { assert(value != null); - _currentExtent.value = value.clamp(minExtent, maxExtent); + _currentExtent.value = value.clamp(minExtent, maxExtent) as double; } double get currentExtent => _currentExtent.value; @@ -599,7 +599,7 @@ class _InheritedResetNotifier extends InheritedNotifier<_ResetNotifier> { return false; } assert(widget is _InheritedResetNotifier); - final _InheritedResetNotifier inheritedNotifier = widget; + final _InheritedResetNotifier inheritedNotifier = widget as _InheritedResetNotifier; final bool wasCalled = inheritedNotifier.notifier._wasCalled; inheritedNotifier.notifier._wasCalled = false; return wasCalled; diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 4603e0446b..709b89d143 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -1375,7 +1375,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien // Clamp the final results to prevent programmatically scrolling to // out-of-paragraph-bounds positions when encountering tall fonts/scripts that // extend past the ascent. - scrollOffset = scrollOffset.clamp(0.0, renderEditable.maxScrollExtent); + scrollOffset = scrollOffset.clamp(0.0, renderEditable.maxScrollExtent) as double; } return scrollOffset; } @@ -1744,7 +1744,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien /// /// This property is typically used to notify the renderer of input gestures /// when [ignorePointer] is true. See [RenderEditable.ignorePointer]. - RenderEditable get renderEditable => _editableKey.currentContext.findRenderObject(); + RenderEditable get renderEditable => _editableKey.currentContext.findRenderObject() as RenderEditable; @override TextEditingValue get textEditingValue => _value; diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index 132d24723a..810dc0a656 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -428,13 +428,13 @@ class _AnimatedFadeOutFadeInState extends ImplicitlyAnimatedWidgetState<_Animate _targetOpacity = visitor( _targetOpacity, widget.isTargetLoaded ? 1.0 : 0.0, - (dynamic value) => Tween(begin: value), - ); + (dynamic value) => Tween(begin: value as double), + ) as Tween; _placeholderOpacity = visitor( _placeholderOpacity, widget.isTargetLoaded ? 0.0 : 1.0, - (dynamic value) => Tween(begin: value), - ); + (dynamic value) => Tween(begin: value as double), + ) as Tween; } @override diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index 8a9b85c1a8..d7643bf427 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -595,7 +595,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { /// /// Use [nearestScope] to start at this node instead of above it. FocusScopeNode get enclosingScope { - return ancestors.firstWhere((FocusNode node) => node is FocusScopeNode, orElse: () => null); + return ancestors.firstWhere((FocusNode node) => node is FocusScopeNode, orElse: () => null) as FocusScopeNode; } /// Returns the size of the attached widget's [RenderObject], in logical @@ -1040,7 +1040,7 @@ class FocusScopeNode extends FocusNode { // found, a scope doesn't have a focusedChild, or a non-scope is // encountered. while (primaryFocus is FocusScopeNode && primaryFocus.focusedChild != null) { - final FocusScopeNode scope = primaryFocus; + final FocusScopeNode scope = primaryFocus as FocusScopeNode; primaryFocus = scope.focusedChild; } if (identical(primaryFocus, this)) { @@ -1426,7 +1426,7 @@ class FocusManager with DiagnosticableTreeMixin { properties.add(FlagProperty('haveScheduledUpdate', value: _haveScheduledUpdate, ifTrue: 'UPDATE SCHEDULED')); properties.add(DiagnosticsProperty('primaryFocus', primaryFocus, defaultValue: null)); properties.add(DiagnosticsProperty('nextFocus', _nextFocus, defaultValue: null)); - final Element element = primaryFocus?.context; + final Element element = primaryFocus?.context as Element; if (element != null) { properties.add(DiagnosticsProperty('primaryFocusCreator', element.debugGetCreatorChain(20))); } diff --git a/packages/flutter/lib/src/widgets/focus_traversal.dart b/packages/flutter/lib/src/widgets/focus_traversal.dart index 528729d559..364065926b 100644 --- a/packages/flutter/lib/src/widgets/focus_traversal.dart +++ b/packages/flutter/lib/src/widgets/focus_traversal.dart @@ -587,7 +587,7 @@ class WidgetOrderFocusTraversalPolicy extends FocusTraversalPolicy with Directio } } while (candidate is FocusScopeNode && candidate.focusedChild != null) { - final FocusScopeNode candidateScope = candidate; + final FocusScopeNode candidateScope = candidate as FocusScopeNode; candidate = candidateScope.focusedChild; } return candidate; diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 2d22044267..131356da3f 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -65,8 +65,8 @@ class ObjectKey extends LocalKey { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final ObjectKey typedOther = other; - return identical(value, typedOther.value); + return other is ObjectKey + && identical(other.value, value); } @override @@ -197,7 +197,7 @@ abstract class GlobalKey> extends Key { assert(element != null); assert(element.widget != null); assert(element.widget.key != null); - final GlobalKey key = element.widget.key; + final GlobalKey key = element.widget.key as GlobalKey; assert(_registry.containsKey(key)); duplicates ??= >{}; final Set elements = duplicates.putIfAbsent(key, () => HashSet()); @@ -314,8 +314,8 @@ class GlobalObjectKey> extends GlobalKey { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final GlobalObjectKey typedOther = other; - return identical(value, typedOther.value); + return other is GlobalObjectKey + && identical(other.value, value); } @override @@ -2957,8 +2957,8 @@ abstract class Element extends DiagnosticableTree implements BuildContext { @protected Element updateChild(Element child, Widget newWidget, dynamic newSlot) { assert(() { - if (newWidget != null && newWidget.key is GlobalKey) { - final GlobalKey key = newWidget.key; + final Key key = newWidget?.key; + if (key is GlobalKey) { key._debugReserveFor(this); } return true; @@ -3015,8 +3015,8 @@ abstract class Element extends DiagnosticableTree implements BuildContext { _active = true; if (parent != null) // Only assign ownership if the parent is non-null _owner = parent.owner; - if (widget.key is GlobalKey) { - final GlobalKey key = widget.key; + final Key key = widget.key; + if (key is GlobalKey) { key._register(this); } _updateInheritance(); @@ -3365,8 +3365,8 @@ abstract class Element extends DiagnosticableTree implements BuildContext { assert(widget != null); assert(depth != null); assert(!_active); - if (widget.key is GlobalKey) { - final GlobalKey key = widget.key; + final Key key = widget.key; + if (key is GlobalKey) { key._unregister(this); } assert(() { @@ -3461,7 +3461,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { renderObject.describeForError('The associated render object was'), ]); } - final RenderBox box = renderObject; + final RenderBox box = renderObject as RenderBox; if (!box.hasSize) { throw FlutterError.fromParts([ ErrorSummary('Cannot get size from a render object that has not been through layout.'), @@ -3568,7 +3568,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { final InheritedElement ancestor = _inheritedWidgets == null ? null : _inheritedWidgets[T]; if (ancestor != null) { assert(ancestor is InheritedElement); - return dependOnInheritedElement(ancestor, aspect: aspect); + return dependOnInheritedElement(ancestor, aspect: aspect) as T; } _hadUnsatisfiedDependencies = true; return null; @@ -3618,7 +3618,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { Element ancestor = _parent; while (ancestor != null && ancestor.widget.runtimeType != T) ancestor = ancestor._parent; - return ancestor?.widget; + return ancestor?.widget as T; } // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189 @@ -3635,7 +3635,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { break; ancestor = ancestor._parent; } - final StatefulElement statefulAncestor = ancestor; + final StatefulElement statefulAncestor = ancestor as StatefulElement; return statefulAncestor?.state; } @@ -3648,8 +3648,8 @@ abstract class Element extends DiagnosticableTree implements BuildContext { break; ancestor = ancestor._parent; } - final StatefulElement statefulAncestor = ancestor; - return statefulAncestor?.state; + final StatefulElement statefulAncestor = ancestor as StatefulElement; + return statefulAncestor?.state as T; } // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189 @@ -3680,7 +3680,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { statefulAncestor = ancestor; ancestor = ancestor._parent; } - return statefulAncestor?.state; + return statefulAncestor?.state as T; } // TODO(a14n): Remove this when it goes to stable, https://github.com/flutter/flutter/pull/44189 @@ -3694,11 +3694,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext { Element ancestor = _parent; while (ancestor != null) { if (ancestor is RenderObjectElement && matcher.check(ancestor.renderObject)) - break; + return ancestor.renderObject; ancestor = ancestor._parent; } - final RenderObjectElement renderObjectAncestor = ancestor; - return renderObjectAncestor?.renderObject; + return null; } @override @@ -3707,11 +3706,10 @@ abstract class Element extends DiagnosticableTree implements BuildContext { Element ancestor = _parent; while (ancestor != null) { if (ancestor is RenderObjectElement && ancestor.renderObject is T) - break; + return ancestor.renderObject as T; ancestor = ancestor._parent; } - final RenderObjectElement renderObjectAncestor = ancestor; - return renderObjectAncestor?.renderObject; + return null; } @override @@ -3978,7 +3976,7 @@ class _ElementDiagnosticableTreeNode extends DiagnosticableTreeNode { @override Map toJsonMap(DiagnosticsSerializationDelegate delegate) { final Map json = super.toJsonMap(delegate); - final Element element = value; + final Element element = value as Element; json['widgetRuntimeType'] = element.widget?.runtimeType?.toString(); json['stateful'] = stateful; return json; @@ -4288,7 +4286,7 @@ class StatelessElement extends ComponentElement { StatelessElement(StatelessWidget widget) : super(widget); @override - StatelessWidget get widget => super.widget; + StatelessWidget get widget => super.widget as StatelessWidget; @override Widget build() => widget.build(this); @@ -4393,7 +4391,7 @@ class StatefulElement extends ComponentElement { // let authors call setState from within didUpdateWidget without triggering // asserts. _dirty = true; - _state._widget = widget; + _state._widget = widget as StatefulWidget; try { _debugSetAllowIgnoredCallsToMarkNeedsBuild(true); final dynamic debugCheckForReturnedFuture = _state.didUpdateWidget(oldWidget) as dynamic; @@ -4511,7 +4509,7 @@ class StatefulElement extends ComponentElement { } return true; }()); - return super.dependOnInheritedElement(ancestor, aspect: aspect); + return super.dependOnInheritedElement(ancestor as InheritedElement, aspect: aspect); } @override @@ -4543,7 +4541,7 @@ abstract class ProxyElement extends ComponentElement { ProxyElement(ProxyWidget widget) : super(widget); @override - ProxyWidget get widget => super.widget; + ProxyWidget get widget => super.widget as ProxyWidget; @override Widget build() => widget.child; @@ -4585,7 +4583,7 @@ class ParentDataElement extends ProxyElement { ParentDataElement(ParentDataWidget widget) : super(widget); @override - ParentDataWidget get widget => super.widget; + ParentDataWidget get widget => super.widget as ParentDataWidget; @override void mount(Element parent, dynamic newSlot) { @@ -4683,7 +4681,7 @@ class InheritedElement extends ProxyElement { InheritedElement(InheritedWidget widget) : super(widget); @override - InheritedWidget get widget => super.widget; + InheritedWidget get widget => super.widget as InheritedWidget; final Map _dependents = HashMap(); @@ -5023,7 +5021,7 @@ abstract class RenderObjectElement extends Element { RenderObjectElement(RenderObjectWidget widget) : super(widget); @override - RenderObjectWidget get widget => super.widget; + RenderObjectWidget get widget => super.widget as RenderObjectWidget; /// The underlying [RenderObject] for this element. @override @@ -5036,7 +5034,7 @@ abstract class RenderObjectElement extends Element { Element ancestor = _parent; while (ancestor != null && ancestor is! RenderObjectElement) ancestor = ancestor._parent; - return ancestor; + return ancestor as RenderObjectElement; } ParentDataElement _findAncestorParentDataElement() { @@ -5426,7 +5424,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement { SingleChildRenderObjectElement(SingleChildRenderObjectWidget widget) : super(widget); @override - SingleChildRenderObjectWidget get widget => super.widget; + SingleChildRenderObjectWidget get widget => super.widget as SingleChildRenderObjectWidget; Element _child; @@ -5457,7 +5455,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement { @override void insertChildRenderObject(RenderObject child, dynamic slot) { - final RenderObjectWithChildMixin renderObject = this.renderObject; + final RenderObjectWithChildMixin renderObject = this.renderObject as RenderObjectWithChildMixin; assert(slot == null); assert(renderObject.debugValidateChild(child)); renderObject.child = child; @@ -5471,7 +5469,7 @@ class SingleChildRenderObjectElement extends RenderObjectElement { @override void removeChildRenderObject(RenderObject child) { - final RenderObjectWithChildMixin renderObject = this.renderObject; + final RenderObjectWithChildMixin renderObject = this.renderObject as RenderObjectWithChildMixin; assert(renderObject.child == child); renderObject.child = null; assert(renderObject == this.renderObject); @@ -5491,7 +5489,7 @@ class MultiChildRenderObjectElement extends RenderObjectElement { super(widget); @override - MultiChildRenderObjectWidget get widget => super.widget; + MultiChildRenderObjectWidget get widget => super.widget as MultiChildRenderObjectWidget; /// The current list of children of this element. /// @@ -5508,15 +5506,17 @@ class MultiChildRenderObjectElement extends RenderObjectElement { @override void insertChildRenderObject(RenderObject child, Element slot) { - final ContainerRenderObjectMixin> renderObject = this.renderObject; + final ContainerRenderObjectMixin> renderObject = + this.renderObject as ContainerRenderObjectMixin>; assert(renderObject.debugValidateChild(child)); renderObject.insert(child, after: slot?.renderObject); assert(renderObject == this.renderObject); } @override - void moveChildRenderObject(RenderObject child, dynamic slot) { - final ContainerRenderObjectMixin> renderObject = this.renderObject; + void moveChildRenderObject(RenderObject child, Element slot) { + final ContainerRenderObjectMixin> renderObject = + this.renderObject as ContainerRenderObjectMixin>; assert(child.parent == renderObject); renderObject.move(child, after: slot?.renderObject); assert(renderObject == this.renderObject); @@ -5524,7 +5524,8 @@ class MultiChildRenderObjectElement extends RenderObjectElement { @override void removeChildRenderObject(RenderObject child) { - final ContainerRenderObjectMixin> renderObject = this.renderObject; + final ContainerRenderObjectMixin> renderObject = + this.renderObject as ContainerRenderObjectMixin>; assert(child.parent == renderObject); renderObject.remove(child); assert(renderObject == this.renderObject); diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 938cf17279..c8e04ea1e3 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -954,7 +954,7 @@ class RawGestureDetectorState extends State { }()); _syncAll(gestures); if (!widget.excludeFromSemantics) { - final RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject(); + final RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject() as RenderSemanticsGestureHandler; _updateSemanticsForRenderObject(semanticsGestureHandler); } } @@ -974,7 +974,7 @@ class RawGestureDetectorState extends State { if (widget.excludeFromSemantics) return; - final RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject(); + final RenderSemanticsGestureHandler semanticsGestureHandler = context.findRenderObject() as RenderSemanticsGestureHandler; assert(() { if (semanticsGestureHandler == null) { throw FlutterError( @@ -1135,7 +1135,7 @@ class _DefaultSemanticsGestureDelegate extends SemanticsGestureDelegate { } GestureTapCallback _getTapHandler(Map recognizers) { - final TapGestureRecognizer tap = recognizers[TapGestureRecognizer]; + final TapGestureRecognizer tap = recognizers[TapGestureRecognizer] as TapGestureRecognizer; if (tap == null) return null; assert(tap is TapGestureRecognizer); @@ -1152,7 +1152,7 @@ class _DefaultSemanticsGestureDelegate extends SemanticsGestureDelegate { } GestureLongPressCallback _getLongPressHandler(Map recognizers) { - final LongPressGestureRecognizer longPress = recognizers[LongPressGestureRecognizer]; + final LongPressGestureRecognizer longPress = recognizers[LongPressGestureRecognizer] as LongPressGestureRecognizer; if (longPress == null) return null; @@ -1170,8 +1170,8 @@ class _DefaultSemanticsGestureDelegate extends SemanticsGestureDelegate { } GestureDragUpdateCallback _getHorizontalDragUpdateHandler(Map recognizers) { - final HorizontalDragGestureRecognizer horizontal = recognizers[HorizontalDragGestureRecognizer]; - final PanGestureRecognizer pan = recognizers[PanGestureRecognizer]; + final HorizontalDragGestureRecognizer horizontal = recognizers[HorizontalDragGestureRecognizer] as HorizontalDragGestureRecognizer; + final PanGestureRecognizer pan = recognizers[PanGestureRecognizer] as PanGestureRecognizer; final GestureDragUpdateCallback horizontalHandler = horizontal == null ? null : @@ -1212,8 +1212,8 @@ class _DefaultSemanticsGestureDelegate extends SemanticsGestureDelegate { } GestureDragUpdateCallback _getVerticalDragUpdateHandler(Map recognizers) { - final VerticalDragGestureRecognizer vertical = recognizers[VerticalDragGestureRecognizer]; - final PanGestureRecognizer pan = recognizers[PanGestureRecognizer]; + final VerticalDragGestureRecognizer vertical = recognizers[VerticalDragGestureRecognizer] as VerticalDragGestureRecognizer; + final PanGestureRecognizer pan = recognizers[PanGestureRecognizer] as PanGestureRecognizer; final GestureDragUpdateCallback verticalHandler = vertical == null ? null : diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index bd7fe1d493..d3da335551 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -73,7 +73,7 @@ enum HeroFlightDirection { // The bounding box for context in ancestorContext coordinate system, or in the global // coordinate system when null. Rect _boundingBoxFor(BuildContext context, [BuildContext ancestorContext]) { - final RenderBox box = context.findRenderObject(); + final RenderBox box = context.findRenderObject() as RenderBox; assert(box != null && box.hasSize); return MatrixUtils.transformRect( box.getTransformTo(ancestorContext?.findRenderObject()), @@ -274,8 +274,8 @@ class Hero extends StatefulWidget { } return true; }()); - final Hero heroWidget = hero.widget; - final _HeroState heroState = hero.state; + final Hero heroWidget = hero.widget as Hero; + final _HeroState heroState = hero.state as _HeroState; if (!isUserGestureTransition || heroWidget.transitionOnUserGestures) { result[tag] = heroState; } else { @@ -286,10 +286,10 @@ class Hero extends StatefulWidget { } void visitor(Element element) { - if (element.widget is Hero) { - final StatefulElement hero = element; - final Hero heroWidget = element.widget; - final Object tag = heroWidget.tag; + final Widget widget = element.widget; + if (widget is Hero) { + final StatefulElement hero = element as StatefulElement; + final Object tag = widget.tag; assert(tag != null); if (Navigator.of(hero) == navigator) { inviteHero(hero, tag); @@ -344,7 +344,7 @@ class _HeroState extends State { void startFlight({ bool shouldIncludedChildInPlaceholder = false }) { _shouldIncludeChild = shouldIncludedChildInPlaceholder; assert(mounted); - final RenderBox box = context.findRenderObject(); + final RenderBox box = context.findRenderObject() as RenderBox; assert(box != null && box.hasSize); setState(() { _placeholderSize = box.size; @@ -489,7 +489,7 @@ class _HeroFlight { animation: _proxyAnimation, child: shuttle, builder: (BuildContext context, Widget child) { - final RenderBox toHeroBox = manifest.toHero.context?.findRenderObject(); + final RenderBox toHeroBox = manifest.toHero.context?.findRenderObject() as RenderBox; if (_aborted || toHeroBox == null || !toHeroBox.attached) { // The toHero no longer exists or it's no longer the flight's destination. // Continue flying while fading out. @@ -501,7 +501,7 @@ class _HeroFlight { } else if (toHeroBox.hasSize) { // The toHero has been laid out. If it's no longer where the hero animation is // supposed to end up then recreate the heroRect tween. - final RenderBox finalRouteBox = manifest.toRoute.subtreeContext?.findRenderObject(); + final RenderBox finalRouteBox = manifest.toRoute.subtreeContext?.findRenderObject() as RenderBox; final Offset toHeroOrigin = toHeroBox.localToGlobal(Offset.zero, ancestor: finalRouteBox); if (toHeroOrigin != heroRectTween.end.topLeft) { final Rect heroRectEnd = toHeroOrigin & heroRectTween.end.size; @@ -882,7 +882,7 @@ class HeroController extends NavigatorObserver { BuildContext fromHeroContext, BuildContext toHeroContext, ) { - final Hero toHero = toHeroContext.widget; + final Hero toHero = toHeroContext.widget as Hero; return toHero.child; }; } diff --git a/packages/flutter/lib/src/widgets/icon_data.dart b/packages/flutter/lib/src/widgets/icon_data.dart index 8b47d0496a..0321d73fcc 100644 --- a/packages/flutter/lib/src/widgets/icon_data.dart +++ b/packages/flutter/lib/src/widgets/icon_data.dart @@ -53,11 +53,11 @@ class IconData { bool operator ==(dynamic other) { if (runtimeType != other.runtimeType) return false; - final IconData typedOther = other; - return codePoint == typedOther.codePoint - && fontFamily == typedOther.fontFamily - && fontPackage == typedOther.fontPackage - && matchTextDirection == typedOther.matchTextDirection; + return other is IconData + && other.codePoint == codePoint + && other.fontFamily == fontFamily + && other.fontPackage == fontPackage + && other.matchTextDirection == matchTextDirection; } @override diff --git a/packages/flutter/lib/src/widgets/icon_theme_data.dart b/packages/flutter/lib/src/widgets/icon_theme_data.dart index c08a8846b2..2feb8ff274 100644 --- a/packages/flutter/lib/src/widgets/icon_theme_data.dart +++ b/packages/flutter/lib/src/widgets/icon_theme_data.dart @@ -81,7 +81,7 @@ class IconThemeData extends Diagnosticable { final Color color; /// An opacity to apply to both explicit and default icon colors. - double get opacity => _opacity?.clamp(0.0, 1.0); + double get opacity => _opacity?.clamp(0.0, 1.0) as double; final double _opacity; /// The default size for icons. @@ -103,10 +103,10 @@ class IconThemeData extends Diagnosticable { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final IconThemeData typedOther = other; - return color == typedOther.color - && opacity == typedOther.opacity - && size == typedOther.size; + return other is IconThemeData + && other.color == color + && other.opacity == opacity + && other.size == size; } @override diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index 8d21f84ef7..e74eddaa3b 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -740,13 +740,13 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState @override void forEachTween(TweenVisitor visitor) { - _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value)); - _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); - _decoration = visitor(_decoration, widget.decoration, (dynamic value) => DecorationTween(begin: value)); - _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => DecorationTween(begin: value)); - _constraints = visitor(_constraints, widget.constraints, (dynamic value) => BoxConstraintsTween(begin: value)); - _margin = visitor(_margin, widget.margin, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); - _transform = visitor(_transform, widget.transform, (dynamic value) => Matrix4Tween(begin: value)); + _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value as AlignmentGeometry)) as AlignmentGeometryTween; + _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value as EdgeInsetsGeometry)) as EdgeInsetsGeometryTween; + _decoration = visitor(_decoration, widget.decoration, (dynamic value) => DecorationTween(begin: value as Decoration)) as DecorationTween; + _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => DecorationTween(begin: value as Decoration)) as DecorationTween; + _constraints = visitor(_constraints, widget.constraints, (dynamic value) => BoxConstraintsTween(begin: value as BoxConstraints)) as BoxConstraintsTween; + _margin = visitor(_margin, widget.margin, (dynamic value) => EdgeInsetsGeometryTween(begin: value as EdgeInsetsGeometry)) as EdgeInsetsGeometryTween; + _transform = visitor(_transform, widget.transform, (dynamic value) => Matrix4Tween(begin: value as Matrix4)) as Matrix4Tween; } @override @@ -829,7 +829,7 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { - _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); + _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value as EdgeInsetsGeometry)) as EdgeInsetsGeometryTween; } @override @@ -923,7 +923,7 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { - _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value)); + _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value as AlignmentGeometry)) as AlignmentGeometryTween; } @override @@ -1069,12 +1069,12 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState visitor) { - _left = visitor(_left, widget.left, (dynamic value) => Tween(begin: value)); - _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value)); - _right = visitor(_right, widget.right, (dynamic value) => Tween(begin: value)); - _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value)); - _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value)); - _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value)); + _left = visitor(_left, widget.left, (dynamic value) => Tween(begin: value as double)) as Tween; + _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value as double)) as Tween; + _right = visitor(_right, widget.right, (dynamic value) => Tween(begin: value as double)) as Tween; + _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value as double)) as Tween; + _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value as double)) as Tween; + _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value as double)) as Tween; } @override @@ -1204,12 +1204,12 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState visitor) { - _start = visitor(_start, widget.start, (dynamic value) => Tween(begin: value)); - _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value)); - _end = visitor(_end, widget.end, (dynamic value) => Tween(begin: value)); - _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value)); - _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value)); - _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value)); + _start = visitor(_start, widget.start, (dynamic value) => Tween(begin: value as double)) as Tween; + _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value as double)) as Tween; + _end = visitor(_end, widget.end, (dynamic value) => Tween(begin: value as double)) as Tween; + _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value as double)) as Tween; + _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value as double)) as Tween; + _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value as double)) as Tween; } @override @@ -1348,7 +1348,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState visitor) { - _opacity = visitor(_opacity, widget.opacity, (dynamic value) => Tween(begin: value)); + _opacity = visitor(_opacity, widget.opacity, (dynamic value) => Tween(begin: value as double)) as Tween; } @override @@ -1463,7 +1463,7 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState visitor) { - _style = visitor(_style, widget.style, (dynamic value) => TextStyleTween(begin: value)); + _style = visitor(_style, widget.style, (dynamic value) => TextStyleTween(begin: value as TextStyle)) as TextStyleTween; } @override @@ -1588,10 +1588,10 @@ class _AnimatedPhysicalModelState extends AnimatedWidgetBaseState visitor) { - _borderRadius = visitor(_borderRadius, widget.borderRadius, (dynamic value) => BorderRadiusTween(begin: value)); - _elevation = visitor(_elevation, widget.elevation, (dynamic value) => Tween(begin: value)); - _color = visitor(_color, widget.color, (dynamic value) => ColorTween(begin: value)); - _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => ColorTween(begin: value)); + _borderRadius = visitor(_borderRadius, widget.borderRadius, (dynamic value) => BorderRadiusTween(begin: value as BorderRadius)) as BorderRadiusTween; + _elevation = visitor(_elevation, widget.elevation, (dynamic value) => Tween(begin: value as double)) as Tween; + _color = visitor(_color, widget.color, (dynamic value) => ColorTween(begin: value as Color)) as ColorTween; + _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => ColorTween(begin: value as Color)) as ColorTween; } @override diff --git a/packages/flutter/lib/src/widgets/inherited_model.dart b/packages/flutter/lib/src/widgets/inherited_model.dart index ea1919c8bf..a04b870011 100644 --- a/packages/flutter/lib/src/widgets/inherited_model.dart +++ b/packages/flutter/lib/src/widgets/inherited_model.dart @@ -127,7 +127,7 @@ abstract class InheritedModel extends InheritedWidget { results.add(model); assert(model.widget is T); - final T modelWidget = model.widget; + final T modelWidget = model.widget as T; if (modelWidget.isSupportedAspect(aspect)) return; @@ -171,7 +171,7 @@ abstract class InheritedModel extends InheritedWidget { final InheritedElement lastModel = models.last; for (InheritedElement model in models) { - final T value = context.dependOnInheritedElement(model, aspect: aspect); + final T value = context.dependOnInheritedElement(model, aspect: aspect) as T; if (model == lastModel) return value; } @@ -187,11 +187,11 @@ class InheritedModelElement extends InheritedElement { InheritedModelElement(InheritedModel widget) : super(widget); @override - InheritedModel get widget => super.widget; + InheritedModel get widget => super.widget as InheritedModel; @override void updateDependencies(Element dependent, Object aspect) { - final Set dependencies = getDependencies(dependent); + final Set dependencies = getDependencies(dependent) as Set; if (dependencies != null && dependencies.isEmpty) return; @@ -199,13 +199,13 @@ class InheritedModelElement extends InheritedElement { setDependencies(dependent, HashSet()); } else { assert(aspect is T); - setDependencies(dependent, (dependencies ?? HashSet())..add(aspect)); + setDependencies(dependent, (dependencies ?? HashSet())..add(aspect as T)); } } @override void notifyDependent(InheritedModel oldWidget, Element dependent) { - final Set dependencies = getDependencies(dependent); + final Set dependencies = getDependencies(dependent) as Set; if (dependencies == null) return; if (dependencies.isEmpty || widget.updateShouldNotifyDependent(oldWidget, dependencies)) diff --git a/packages/flutter/lib/src/widgets/inherited_notifier.dart b/packages/flutter/lib/src/widgets/inherited_notifier.dart index dce4e5e839..43d47a32cf 100644 --- a/packages/flutter/lib/src/widgets/inherited_notifier.dart +++ b/packages/flutter/lib/src/widgets/inherited_notifier.dart @@ -79,7 +79,7 @@ class _InheritedNotifierElement extends InheritedElement { } @override - InheritedNotifier get widget => super.widget; + InheritedNotifier get widget => super.widget as InheritedNotifier; bool _dirty = false; diff --git a/packages/flutter/lib/src/widgets/inherited_theme.dart b/packages/flutter/lib/src/widgets/inherited_theme.dart index aceeae9bc9..ecae20ab22 100644 --- a/packages/flutter/lib/src/widgets/inherited_theme.dart +++ b/packages/flutter/lib/src/widgets/inherited_theme.dart @@ -117,7 +117,7 @@ abstract class InheritedTheme extends InheritedWidget { final Set themeTypes = {}; context.visitAncestorElements((Element ancestor) { if (ancestor is InheritedElement && ancestor.widget is InheritedTheme) { - final InheritedTheme theme = ancestor.widget; + final InheritedTheme theme = ancestor.widget as InheritedTheme; final Type themeType = theme.runtimeType; // Only remember the first theme of any type. This assumes // that inherited themes completely shadow ancestors of the diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index c479b3bdb5..71382f24d1 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -43,10 +43,10 @@ class _LayoutBuilderElement extends RenderOb _LayoutBuilderElement(ConstrainedLayoutBuilder widget) : super(widget); @override - ConstrainedLayoutBuilder get widget => super.widget; + ConstrainedLayoutBuilder get widget => super.widget as ConstrainedLayoutBuilder; @override - RenderConstrainedLayoutBuilder get renderObject => super.renderObject; + RenderConstrainedLayoutBuilder get renderObject => super.renderObject as RenderConstrainedLayoutBuilder; Element _child; diff --git a/packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart b/packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart index 7b6cf1380c..96673923f4 100644 --- a/packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart @@ -245,7 +245,7 @@ class FixedExtentScrollController extends ScrollController { 'The selectedItem property cannot be read when multiple scroll views are ' 'attached to the same FixedExtentScrollController.', ); - final _FixedExtentScrollPosition position = this.position; + final _FixedExtentScrollPosition position = this.position as _FixedExtentScrollPosition; return position.itemIndex; } @@ -265,7 +265,7 @@ class FixedExtentScrollController extends ScrollController { } await Future.wait(>[ - for (_FixedExtentScrollPosition position in positions) + for (_FixedExtentScrollPosition position in positions.cast<_FixedExtentScrollPosition>()) position.animateTo( itemIndex * position.itemExtent, duration: duration, @@ -279,7 +279,7 @@ class FixedExtentScrollController extends ScrollController { /// Jumps the item index position from its current value to the given value, /// without animation, and without checking if the new value is in range. void jumpToItem(int itemIndex) { - for (_FixedExtentScrollPosition position in positions) { + for (_FixedExtentScrollPosition position in positions.cast<_FixedExtentScrollPosition>()) { position.jumpTo(itemIndex * position.itemExtent); } } @@ -386,7 +386,7 @@ class _FixedExtentScrollPosition extends ScrollPositionWithSingleContext impleme ); static double _getItemExtentFromScrollContext(ScrollContext context) { - final _FixedExtentScrollableState scrollable = context; + final _FixedExtentScrollableState scrollable = context as _FixedExtentScrollableState; return scrollable.itemExtent; } @@ -451,7 +451,7 @@ class _FixedExtentScrollable extends Scrollable { class _FixedExtentScrollableState extends ScrollableState { double get itemExtent { // Downcast because only _FixedExtentScrollable can make _FixedExtentScrollableState. - final _FixedExtentScrollable actualWidget = widget; + final _FixedExtentScrollable actualWidget = widget as _FixedExtentScrollable; return actualWidget.itemExtent; } } @@ -483,7 +483,7 @@ class FixedExtentScrollPhysics extends ScrollPhysics { 'the FixedExtentScrollController' ); - final _FixedExtentScrollPosition metrics = position; + final _FixedExtentScrollPosition metrics = position as _FixedExtentScrollPosition; // Scenario 1: // If we're out of range and not headed back in range, defer to the parent @@ -711,7 +711,7 @@ class _ListWheelScrollViewState extends State { super.initState(); scrollController = widget.controller ?? FixedExtentScrollController(); if (widget.controller is FixedExtentScrollController) { - final FixedExtentScrollController controller = widget.controller; + final FixedExtentScrollController controller = widget.controller as FixedExtentScrollController; _lastReportedItemIndex = controller.initialItem; } } @@ -736,7 +736,7 @@ class _ListWheelScrollViewState extends State { && widget.onSelectedItemChanged != null && notification is ScrollUpdateNotification && notification.metrics is FixedExtentMetrics) { - final FixedExtentMetrics metrics = notification.metrics; + final FixedExtentMetrics metrics = notification.metrics as FixedExtentMetrics; final int currentItemIndex = metrics.itemIndex; if (currentItemIndex != _lastReportedItemIndex) { _lastReportedItemIndex = currentItemIndex; @@ -776,10 +776,10 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana ListWheelElement(ListWheelViewport widget) : super(widget); @override - ListWheelViewport get widget => super.widget; + ListWheelViewport get widget => super.widget as ListWheelViewport; @override - RenderListWheelViewport get renderObject => super.renderObject; + RenderListWheelViewport get renderObject => super.renderObject as RenderListWheelViewport; // We inflate widgets at two different times: // 1. When we ourselves are told to rebuild (see performRebuild). @@ -870,11 +870,11 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana @override Element updateChild(Element child, Widget newWidget, dynamic newSlot) { - final ListWheelParentData oldParentData = child?.renderObject?.parentData; + final ListWheelParentData oldParentData = child?.renderObject?.parentData as ListWheelParentData; final Element newChild = super.updateChild(child, newWidget, newSlot); - final ListWheelParentData newParentData = newChild?.renderObject?.parentData; + final ListWheelParentData newParentData = newChild?.renderObject?.parentData as ListWheelParentData; if (newParentData != null) { - newParentData.index = newSlot; + newParentData.index = newSlot as int; if (oldParentData != null) newParentData.offset = oldParentData.offset; } @@ -886,7 +886,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana void insertChildRenderObject(RenderObject child, int slot) { final RenderListWheelViewport renderObject = this.renderObject; assert(renderObject.debugValidateChild(child)); - renderObject.insert(child, after: _childElements[slot - 1]?.renderObject); + renderObject.insert(child as RenderBox, after: _childElements[slot - 1]?.renderObject as RenderBox); assert(renderObject == this.renderObject); } @@ -901,7 +901,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana @override void removeChildRenderObject(RenderObject child) { assert(child.parent == renderObject); - renderObject.remove(child); + renderObject.remove(child as RenderBox); } @override @@ -1018,7 +1018,7 @@ class ListWheelViewport extends RenderObjectWidget { @override RenderListWheelViewport createRenderObject(BuildContext context) { - final ListWheelElement childManager = context; + final ListWheelElement childManager = context as ListWheelElement; return RenderListWheelViewport( childManager: childManager, offset: offset, diff --git a/packages/flutter/lib/src/widgets/localizations.dart b/packages/flutter/lib/src/widgets/localizations.dart index 2161222dbe..5ae0b6e7eb 100644 --- a/packages/flutter/lib/src/widgets/localizations.dart +++ b/packages/flutter/lib/src/widgets/localizations.dart @@ -535,12 +535,12 @@ class _LocalizationsState extends State { T resourcesFor(Type type) { assert(type != null); - final T resources = _typeToResources[type]; + final T resources = _typeToResources[type] as T; return resources; } TextDirection get _textDirection { - final WidgetsLocalizations resources = _typeToResources[WidgetsLocalizations]; + final WidgetsLocalizations resources = _typeToResources[WidgetsLocalizations] as WidgetsLocalizations; assert(resources != null); return resources.textDirection; } diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index ad4371641e..39230555d9 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -535,21 +535,21 @@ class MediaQueryData { bool operator ==(Object other) { if (other.runtimeType != runtimeType) return false; - final MediaQueryData typedOther = other; - return typedOther.size == size - && typedOther.devicePixelRatio == devicePixelRatio - && typedOther.textScaleFactor == textScaleFactor - && typedOther.platformBrightness == platformBrightness - && typedOther.padding == padding - && typedOther.viewPadding == viewPadding - && typedOther.viewInsets == viewInsets - && typedOther.physicalDepth == physicalDepth - && typedOther.alwaysUse24HourFormat == alwaysUse24HourFormat - && typedOther.highContrast == highContrast - && typedOther.disableAnimations == disableAnimations - && typedOther.invertColors == invertColors - && typedOther.accessibleNavigation == accessibleNavigation - && typedOther.boldText == boldText; + return other is MediaQueryData + && other.size == size + && other.devicePixelRatio == devicePixelRatio + && other.textScaleFactor == textScaleFactor + && other.platformBrightness == platformBrightness + && other.padding == padding + && other.viewPadding == viewPadding + && other.viewInsets == viewInsets + && other.physicalDepth == physicalDepth + && other.alwaysUse24HourFormat == alwaysUse24HourFormat + && other.highContrast == highContrast + && other.disableAnimations == disableAnimations + && other.invertColors == invertColors + && other.accessibleNavigation == accessibleNavigation + && other.boldText == boldText; } @override diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index 5f64a5b77a..1a1ea57b8f 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -152,7 +152,7 @@ class AnimatedModalBarrier extends AnimatedWidget { /// /// * [ModalRoute.barrierColor], which controls this property for the /// [AnimatedModalBarrier] built by [ModalRoute] pages. - Animation get color => listenable; + Animation get color => listenable as Animation; /// Whether touching the barrier will pop the current route off the [Navigator]. /// diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 0831bfda1b..344249fec6 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -1626,7 +1626,7 @@ class NavigatorState extends State with TickerProviderStateMixin { isInitialRoute: _history.isEmpty, arguments: arguments, ); - Route route = widget.onGenerateRoute(settings); + Route route = widget.onGenerateRoute(settings) as Route; if (route == null && !allowNull) { assert(() { if (widget.onUnknownRoute == null) { @@ -1641,7 +1641,7 @@ class NavigatorState extends State with TickerProviderStateMixin { } return true; }()); - route = widget.onUnknownRoute(settings); + route = widget.onUnknownRoute(settings) as Route; assert(() { if (route == null) { throw FlutterError.fromParts([ @@ -2073,7 +2073,7 @@ class NavigatorState extends State with TickerProviderStateMixin { /// to define the route's `willPop` method. @optionalTypeArgs Future maybePop([ T result ]) async { - final Route route = _history.last; + final Route route = _history.last as Route; assert(route._navigator == this); final RoutePopDisposition disposition = await route.willPop(); if (disposition != RoutePopDisposition.bubble && mounted) { diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index b53a02774e..213f85c6d6 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -610,7 +610,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont ScrollActivity createInnerBallisticScrollActivity(_NestedScrollPosition position, double velocity) { return position.createBallisticScrollActivity( position.physics.createBallisticSimulation( - velocity == 0 ? position : _getMetrics(position, velocity), + velocity == 0 ? position as ScrollMetrics : _getMetrics(position, velocity), velocity, ), mode: _NestedBallisticScrollActivityMode.inner, @@ -621,7 +621,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont assert(innerPosition != null); double pixels, minRange, maxRange, correctionOffset, extra; if (innerPosition.pixels == innerPosition.minScrollExtent) { - pixels = _outerPosition.pixels.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent); // TODO(ianh): gracefully handle out-of-range outer positions + pixels = _outerPosition.pixels.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent) as double; // TODO(ianh): gracefully handle out-of-range outer positions minRange = _outerPosition.minScrollExtent; maxRange = _outerPosition.maxScrollExtent; assert(minRange <= maxRange); @@ -687,7 +687,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont double unnestOffset(double value, _NestedScrollPosition source) { if (source == _outerPosition) - return value.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent); + return value.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent) as double; if (value < source.minScrollExtent) return value - source.minScrollExtent + _outerPosition.minScrollExtent; return value - source.minScrollExtent + _outerPosition.maxScrollExtent; @@ -695,7 +695,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont double nestOffset(double value, _NestedScrollPosition target) { if (target == _outerPosition) - return value.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent); + return value.clamp(_outerPosition.minScrollExtent, _outerPosition.maxScrollExtent) as double; if (value < _outerPosition.minScrollExtent) return value - _outerPosition.minScrollExtent + target.minScrollExtent; if (value > _outerPosition.maxScrollExtent) @@ -987,7 +987,7 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele // The logic for max is equivalent but on the other side. final double max = delta > 0.0 ? double.infinity : math.max(maxScrollExtent, pixels); final double oldPixels = pixels; - final double newPixels = (pixels - delta).clamp(min, max); + final double newPixels = (pixels - delta).clamp(min, max) as double; final double clampedDelta = newPixels - pixels; if (clampedDelta == 0.0) return delta; @@ -1152,7 +1152,7 @@ class _NestedInnerBallisticScrollActivity extends BallisticScrollActivity { final _NestedScrollCoordinator coordinator; @override - _NestedScrollPosition get delegate => super.delegate; + _NestedScrollPosition get delegate => super.delegate as _NestedScrollPosition; @override void resetActivity() { @@ -1185,7 +1185,7 @@ class _NestedOuterBallisticScrollActivity extends BallisticScrollActivity { final _NestedScrollMetrics metrics; @override - _NestedScrollPosition get delegate => super.delegate; + _NestedScrollPosition get delegate => super.delegate as _NestedScrollPosition; @override void resetActivity() { @@ -1215,7 +1215,7 @@ class _NestedOuterBallisticScrollActivity extends BallisticScrollActivity { done = true; } } else { - value = value.clamp(metrics.minRange, metrics.maxRange); + value = value.clamp(metrics.minRange, metrics.maxRange) as double; done = true; } final bool result = super.applyMoveTo(value + metrics.correctionOffset); diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index b769712db6..39b7e57e4b 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -508,10 +508,10 @@ class _TheatreElement extends RenderObjectElement { super(widget); @override - _Theatre get widget => super.widget; + _Theatre get widget => super.widget as _Theatre; @override - _RenderTheatre get renderObject => super.renderObject; + _RenderTheatre get renderObject => super.renderObject as _RenderTheatre; Element _onstage; static final Object _onstageSlot = Object(); @@ -524,10 +524,10 @@ class _TheatreElement extends RenderObjectElement { assert(renderObject.debugValidateChild(child)); if (slot == _onstageSlot) { assert(child is RenderStack); - renderObject.child = child; + renderObject.child = child as RenderStack; } else { assert(slot == null || slot is Element); - renderObject.insert(child, after: slot?.renderObject); + renderObject.insert(child, after: slot?.renderObject as RenderBox); } } @@ -536,14 +536,14 @@ class _TheatreElement extends RenderObjectElement { if (slot == _onstageSlot) { renderObject.remove(child); assert(child is RenderStack); - renderObject.child = child; + renderObject.child = child as RenderStack; } else { assert(slot == null || slot is Element); if (renderObject.child == child) { renderObject.child = null; - renderObject.insert(child, after: slot?.renderObject); + renderObject.insert(child, after: slot?.renderObject as RenderBox); } else { - renderObject.move(child, after: slot?.renderObject); + renderObject.move(child, after: slot?.renderObject as RenderBox); } } } @@ -675,7 +675,7 @@ class _RenderTheatre extends RenderBox ); if (child == lastChild) break; - final StackParentData childParentData = child.parentData; + final StackParentData childParentData = child.parentData as StackParentData; child = childParentData.nextSibling; count += 1; } diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index 9aac078ca1..ec610e50f1 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -183,17 +183,17 @@ class _GlowingOverscrollIndicatorState extends State assert(notification.overscroll != 0.0); if (notification.dragDetails != null) { assert(notification.dragDetails.globalPosition != null); - final RenderBox renderer = notification.context.findRenderObject(); + final RenderBox renderer = notification.context.findRenderObject() as RenderBox; assert(renderer != null); assert(renderer.hasSize); final Size size = renderer.size; final Offset position = renderer.globalToLocal(notification.dragDetails.globalPosition); switch (notification.metrics.axis) { case Axis.horizontal: - controller.pull(notification.overscroll.abs(), size.width, position.dy.clamp(0.0, size.height), size.height); + controller.pull(notification.overscroll.abs(), size.width, position.dy.clamp(0.0, size.height) as double, size.height); break; case Axis.vertical: - controller.pull(notification.overscroll.abs(), size.height, position.dx.clamp(0.0, size.width), size.width); + controller.pull(notification.overscroll.abs(), size.height, position.dx.clamp(0.0, size.width) as double, size.width); break; } } @@ -335,9 +335,9 @@ class _GlowController extends ChangeNotifier { assert(velocity >= 0.0); _pullRecedeTimer?.cancel(); _pullRecedeTimer = null; - velocity = velocity.clamp(_minVelocity, _maxVelocity); + velocity = velocity.clamp(_minVelocity, _maxVelocity) as double; _glowOpacityTween.begin = _state == _GlowState.idle ? 0.3 : _glowOpacity.value; - _glowOpacityTween.end = (velocity * _velocityGlowFactor).clamp(_glowOpacityTween.begin, _maxOpacity); + _glowOpacityTween.end = (velocity * _velocityGlowFactor).clamp(_glowOpacityTween.begin, _maxOpacity) as double; _glowSizeTween.begin = _glowSize.value; _glowSizeTween.end = math.min(0.025 + 7.5e-7 * velocity * velocity, 1.0); _glowController.duration = Duration(milliseconds: (0.15 + velocity * 0.02).round()); diff --git a/packages/flutter/lib/src/widgets/page_storage.dart b/packages/flutter/lib/src/widgets/page_storage.dart index f39e63a37d..137c55ae6d 100644 --- a/packages/flutter/lib/src/widgets/page_storage.dart +++ b/packages/flutter/lib/src/widgets/page_storage.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:flutter/foundation.dart'; + import 'framework.dart'; /// A [ValueKey] that defines where [PageStorage] values will be saved. @@ -48,12 +50,8 @@ class _StorageEntryIdentifier { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final _StorageEntryIdentifier typedOther = other; - for (int index = 0; index < keys.length; index += 1) { - if (keys[index] != typedOther.keys[index]) - return false; - } - return true; + return other is _StorageEntryIdentifier + && listEquals>(other.keys, keys); } @override diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index d6fb200c34..058fec7f54 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -184,7 +184,7 @@ class PageController extends ScrollController { 'The page property cannot be read when multiple PageViews are attached to ' 'the same PageController.', ); - final _PagePosition position = this.position; + final _PagePosition position = this.position as _PagePosition; return position.page; } @@ -199,7 +199,7 @@ class PageController extends ScrollController { @required Duration duration, @required Curve curve, }) { - final _PagePosition position = this.position; + final _PagePosition position = this.position as _PagePosition; return position.animateTo( position.getPixelsFromPage(page.toDouble()), duration: duration, @@ -212,7 +212,7 @@ class PageController extends ScrollController { /// Jumps the page position from its current value to the given value, /// without animation, and without checking if the new value is in range. void jumpToPage(int page) { - final _PagePosition position = this.position; + final _PagePosition position = this.position as _PagePosition; position.jumpTo(position.getPixelsFromPage(page.toDouble())); } @@ -251,7 +251,7 @@ class PageController extends ScrollController { @override void attach(ScrollPosition position) { super.attach(position); - final _PagePosition pagePosition = position; + final _PagePosition pagePosition = position as _PagePosition; pagePosition.viewportFraction = viewportFraction; } } @@ -372,7 +372,7 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri pixels == null || (minScrollExtent != null && maxScrollExtent != null), 'Page value is only available after content dimensions are established.', ); - return pixels == null ? null : getPageFromPixels(pixels.clamp(minScrollExtent, maxScrollExtent), viewportDimension); + return pixels == null ? null : getPageFromPixels(pixels.clamp(minScrollExtent, maxScrollExtent) as double, viewportDimension); } @override @@ -383,7 +383,7 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri @override void restoreScrollOffset() { if (pixels == null) { - final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext); + final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext) as double; if (value != null) _pageToUseOnStartup = value; } @@ -499,7 +499,7 @@ class PageScrollPhysics extends ScrollPhysics { (velocity >= 0.0 && position.pixels >= position.maxScrollExtent)) return super.createBallisticSimulation(position, velocity); final Tolerance tolerance = this.tolerance; - final double target = _getTargetPixels(position, tolerance, velocity); + final double target = _getTargetPixels(position as ScrollPosition, tolerance, velocity); if (target != position.pixels) return ScrollSpringSimulation(spring, position.pixels, target, velocity, tolerance: tolerance); return null; @@ -806,7 +806,7 @@ class _PageViewState extends State { return NotificationListener( onNotification: (ScrollNotification notification) { if (notification.depth == 0 && widget.onPageChanged != null && notification is ScrollUpdateNotification) { - final PageMetrics metrics = notification.metrics; + final PageMetrics metrics = notification.metrics as PageMetrics; final int currentPage = metrics.page.round(); if (currentPage != _lastReportedPage) { _lastReportedPage = currentPage; diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 7e567d19f8..850b30b8da 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -763,7 +763,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute of(BuildContext context) { final _ModalScopeStatus widget = context.dependOnInheritedWidgetOfExactType<_ModalScopeStatus>(); - return widget?.route; + return widget?.route as ModalRoute; } /// Schedule a call to [buildTransitions]. diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart index 78a9743980..15fcaedd44 100644 --- a/packages/flutter/lib/src/widgets/scroll_activity.dart +++ b/packages/flutter/lib/src/widgets/scroll_activity.dart @@ -433,21 +433,21 @@ class DragScrollActivity extends ScrollActivity { void dispatchScrollStartNotification(ScrollMetrics metrics, BuildContext context) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragStartDetails); - ScrollStartNotification(metrics: metrics, context: context, dragDetails: lastDetails).dispatch(context); + ScrollStartNotification(metrics: metrics, context: context, dragDetails: lastDetails as DragStartDetails).dispatch(context); } @override void dispatchScrollUpdateNotification(ScrollMetrics metrics, BuildContext context, double scrollDelta) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragUpdateDetails); - ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta, dragDetails: lastDetails).dispatch(context); + ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta, dragDetails: lastDetails as DragUpdateDetails).dispatch(context); } @override void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragUpdateDetails); - OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, dragDetails: lastDetails).dispatch(context); + OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, dragDetails: lastDetails as DragUpdateDetails).dispatch(context); } @override diff --git a/packages/flutter/lib/src/widgets/scroll_position.dart b/packages/flutter/lib/src/widgets/scroll_position.dart index 49e7b3bdd8..8810de6c85 100644 --- a/packages/flutter/lib/src/widgets/scroll_position.dart +++ b/packages/flutter/lib/src/widgets/scroll_position.dart @@ -381,7 +381,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { @protected void restoreScrollOffset() { if (pixels == null) { - final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext); + final double value = PageStorage.of(context.storageContext)?.readState(context.storageContext) as double; if (value != null) correctPixels(value); } @@ -543,16 +543,16 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { double target; switch (alignmentPolicy) { case ScrollPositionAlignmentPolicy.explicit: - target = viewport.getOffsetToReveal(object, alignment).offset.clamp(minScrollExtent, maxScrollExtent); + target = viewport.getOffsetToReveal(object, alignment).offset.clamp(minScrollExtent, maxScrollExtent) as double; break; case ScrollPositionAlignmentPolicy.keepVisibleAtEnd: - target = viewport.getOffsetToReveal(object, 1.0).offset.clamp(minScrollExtent, maxScrollExtent); + target = viewport.getOffsetToReveal(object, 1.0).offset.clamp(minScrollExtent, maxScrollExtent) as double; if (target < pixels) { target = pixels; } break; case ScrollPositionAlignmentPolicy.keepVisibleAtStart: - target = viewport.getOffsetToReveal(object, 0.0).offset.clamp(minScrollExtent, maxScrollExtent); + target = viewport.getOffsetToReveal(object, 0.0).offset.clamp(minScrollExtent, maxScrollExtent) as double; if (target > pixels) { target = pixels; } @@ -641,7 +641,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { assert(clamp != null); if (clamp) - to = to.clamp(minScrollExtent, maxScrollExtent); + to = to.clamp(minScrollExtent, maxScrollExtent) as double; return super.moveTo(to, duration: duration, curve: curve); } diff --git a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart index 572222b76d..894e6754e9 100644 --- a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart +++ b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart @@ -91,7 +91,7 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc return; } activity.updateDelegate(this); - final ScrollPositionWithSingleContext typedOther = other; + final ScrollPositionWithSingleContext typedOther = other as ScrollPositionWithSingleContext; _userScrollDirection = typedOther._userScrollDirection; assert(_currentDrag == null); if (typedOther._currentDrag != null) { diff --git a/packages/flutter/lib/src/widgets/scroll_simulation.dart b/packages/flutter/lib/src/widgets/scroll_simulation.dart index dd4d0fc637..25141da0f4 100644 --- a/packages/flutter/lib/src/widgets/scroll_simulation.dart +++ b/packages/flutter/lib/src/widgets/scroll_simulation.dart @@ -212,13 +212,13 @@ class ClampingScrollSimulation extends Simulation { @override double x(double time) { - final double t = (time / _duration).clamp(0.0, 1.0); + final double t = (time / _duration).clamp(0.0, 1.0) as double; return position + _distance * _flingDistancePenetration(t) * velocity.sign; } @override double dx(double time) { - final double t = (time / _duration).clamp(0.0, 1.0); + final double t = (time / _duration).clamp(0.0, 1.0) as double; return _distance * _flingVelocityPenetration(t) * velocity.sign / _duration; } diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index da5125be77..193d8be22e 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -481,7 +481,7 @@ class ScrollableState extends State with TickerProviderStateMixin return; _shouldIgnorePointer = value; if (_ignorePointerKey.currentContext != null) { - final RenderIgnorePointer renderBox = _ignorePointerKey.currentContext.findRenderObject(); + final RenderIgnorePointer renderBox = _ignorePointerKey.currentContext.findRenderObject() as RenderIgnorePointer; renderBox.ignoring = _shouldIgnorePointer; } } @@ -576,7 +576,7 @@ class ScrollableState extends State with TickerProviderStateMixin if (_physics != null && !_physics.shouldAcceptUserOffset(position)) { return; } - final double targetScrollOffset = _targetScrollOffsetForPointerScroll(event); + final double targetScrollOffset = _targetScrollOffsetForPointerScroll(event as PointerScrollEvent); if (targetScrollOffset != position.pixels) { position.jumpTo(targetScrollOffset); } diff --git a/packages/flutter/lib/src/widgets/scrollbar.dart b/packages/flutter/lib/src/widgets/scrollbar.dart index bf997e9fe4..6a324b884f 100644 --- a/packages/flutter/lib/src/widgets/scrollbar.dart +++ b/packages/flutter/lib/src/widgets/scrollbar.dart @@ -240,7 +240,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { // isn't less than the absolute minimum size. // _totalContentExtent >= viewportDimension, so (_totalContentExtent - _mainAxisPadding) > 0 final double fractionVisible = ((_lastMetrics.extentInside - _mainAxisPadding) / (_totalContentExtent - _mainAxisPadding)) - .clamp(0.0, 1.0); + .clamp(0.0, 1.0) as double; final double thumbExtent = math.max( math.min(_trackExtent, minOverscrollLength), @@ -267,7 +267,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { // The `thumbExtent` should be no greater than `trackSize`, otherwise // the scrollbar may scroll towards the wrong direction. - return thumbExtent.clamp(newMinLength, _trackExtent); + return thumbExtent.clamp(newMinLength, _trackExtent) as double; } @override @@ -311,7 +311,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { final double scrollableExtent = metrics.maxScrollExtent - metrics.minScrollExtent; final double fractionPast = (scrollableExtent > 0) - ? ((metrics.pixels - metrics.minScrollExtent) / scrollableExtent).clamp(0.0, 1.0) + ? ((metrics.pixels - metrics.minScrollExtent) / scrollableExtent).clamp(0.0, 1.0) as double : 0; return (_isReversed ? 1 - fractionPast : fractionPast) * (_trackExtent - thumbExtent); diff --git a/packages/flutter/lib/src/widgets/shortcuts.dart b/packages/flutter/lib/src/widgets/shortcuts.dart index f96b9ef0d1..9b25b847c7 100644 --- a/packages/flutter/lib/src/widgets/shortcuts.dart +++ b/packages/flutter/lib/src/widgets/shortcuts.dart @@ -89,8 +89,8 @@ class KeySet extends Diagnosticable { if (other.runtimeType != runtimeType) { return false; } - final KeySet typedOther = other; - return setEquals(_keys, typedOther._keys); + return other is KeySet + && setEquals(other._keys, _keys); } @override diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index 151c696fc6..eebd797fef 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -575,7 +575,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix if (target is! RenderBox) return RevealedOffset(offset: offset.pixels, rect: rect); - final RenderBox targetBox = target; + final RenderBox targetBox = target as RenderBox; final Matrix4 transform = targetBox.getTransformTo(child); final Rect bounds = MatrixUtils.transformRect(transform, rect); final Size contentSize = child.size; diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index c2903e6003..c11ace67ab 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -815,7 +815,7 @@ class SliverList extends SliverMultiBoxAdaptorWidget { @override RenderSliverList createRenderObject(BuildContext context) { - final SliverMultiBoxAdaptorElement element = context; + final SliverMultiBoxAdaptorElement element = context as SliverMultiBoxAdaptorElement; return RenderSliverList(childManager: element); } } @@ -878,7 +878,7 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { @override RenderSliverFixedExtentList createRenderObject(BuildContext context) { - final SliverMultiBoxAdaptorElement element = context; + final SliverMultiBoxAdaptorElement element = context as SliverMultiBoxAdaptorElement; return RenderSliverFixedExtentList(childManager: element, itemExtent: itemExtent); } @@ -998,7 +998,7 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { @override RenderSliverGrid createRenderObject(BuildContext context) { - final SliverMultiBoxAdaptorElement element = context; + final SliverMultiBoxAdaptorElement element = context as SliverMultiBoxAdaptorElement; return RenderSliverGrid(childManager: element, gridDelegate: gridDelegate); } @@ -1085,7 +1085,7 @@ class _SliverFillViewportRenderObjectWidget extends SliverMultiBoxAdaptorWidget @override RenderSliverFillViewport createRenderObject(BuildContext context) { - final SliverMultiBoxAdaptorElement element = context; + final SliverMultiBoxAdaptorElement element = context as SliverMultiBoxAdaptorElement; return RenderSliverFillViewport(childManager: element, viewportFraction: viewportFraction); } @@ -1175,10 +1175,10 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render SliverMultiBoxAdaptorElement(SliverMultiBoxAdaptorWidget widget) : super(widget); @override - SliverMultiBoxAdaptorWidget get widget => super.widget; + SliverMultiBoxAdaptorWidget get widget => super.widget as SliverMultiBoxAdaptorWidget; @override - RenderSliverMultiBoxAdaptor get renderObject => super.renderObject; + RenderSliverMultiBoxAdaptor get renderObject => super.renderObject as RenderSliverMultiBoxAdaptor; @override void update(covariant SliverMultiBoxAdaptorWidget newWidget) { @@ -1220,9 +1220,9 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render final Element newChild = updateChild(newChildren[index], _build(index), index); if (newChild != null) { _childElements[index] = newChild; - final SliverMultiBoxAdaptorParentData parentData = newChild.renderObject.parentData; + final SliverMultiBoxAdaptorParentData parentData = newChild.renderObject.parentData as SliverMultiBoxAdaptorParentData; if (!parentData.keptAlive) - _currentBeforeChild = newChild.renderObject; + _currentBeforeChild = newChild.renderObject as RenderBox; } else { _childElements.remove(index); } @@ -1266,7 +1266,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render owner.buildScope(this, () { final bool insertFirst = after == null; assert(insertFirst || _childElements[index-1] != null); - _currentBeforeChild = insertFirst ? null : _childElements[index-1].renderObject; + _currentBeforeChild = insertFirst ? null : (_childElements[index-1].renderObject as RenderBox); Element newChild; try { _currentlyUpdatingChildIndex = index; @@ -1284,9 +1284,9 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render @override Element updateChild(Element child, Widget newWidget, dynamic newSlot) { - final SliverMultiBoxAdaptorParentData oldParentData = child?.renderObject?.parentData; + final SliverMultiBoxAdaptorParentData oldParentData = child?.renderObject?.parentData as SliverMultiBoxAdaptorParentData; final Element newChild = super.updateChild(child, newWidget, newSlot); - final SliverMultiBoxAdaptorParentData newParentData = newChild?.renderObject?.parentData; + final SliverMultiBoxAdaptorParentData newParentData = newChild?.renderObject?.parentData as SliverMultiBoxAdaptorParentData; // Preserve the old layoutOffset if the renderObject was swapped out. if (oldParentData != newParentData && oldParentData != null && newParentData != null) { @@ -1390,7 +1390,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render @override void didAdoptChild(RenderBox child) { assert(_currentlyUpdatingChildIndex != null); - final SliverMultiBoxAdaptorParentData childParentData = child.parentData; + final SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData; childParentData.index = _currentlyUpdatingChildIndex; } @@ -1406,9 +1406,9 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render assert(slot != null); assert(_currentlyUpdatingChildIndex == slot); assert(renderObject.debugValidateChild(child)); - renderObject.insert(child, after: _currentBeforeChild); + renderObject.insert(child as RenderBox, after: _currentBeforeChild); assert(() { - final SliverMultiBoxAdaptorParentData childParentData = child.parentData; + final SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData; assert(slot == childParentData.index); return true; }()); @@ -1418,13 +1418,13 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render void moveChildRenderObject(covariant RenderObject child, int slot) { assert(slot != null); assert(_currentlyUpdatingChildIndex == slot); - renderObject.move(child, after: _currentBeforeChild); + renderObject.move(child as RenderBox, after: _currentBeforeChild); } @override void removeChildRenderObject(covariant RenderObject child) { assert(_currentlyUpdatingChildIndex != null); - renderObject.remove(child); + renderObject.remove(child as RenderBox); } @override @@ -1438,7 +1438,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render @override void debugVisitOnstageChildren(ElementVisitor visitor) { _childElements.values.where((Element child) { - final SliverMultiBoxAdaptorParentData parentData = child.renderObject.parentData; + final SliverMultiBoxAdaptorParentData parentData = child.renderObject.parentData as SliverMultiBoxAdaptorParentData; double itemExtent; switch (renderObject.constraints.axis) { case Axis.horizontal: @@ -1936,7 +1936,7 @@ class _SliverOffstageElement extends SingleChildRenderObjectElement { _SliverOffstageElement(SliverOffstage widget) : super(widget); @override - SliverOffstage get widget => super.widget; + SliverOffstage get widget => super.widget as SliverOffstage; @override void debugVisitOnstageChildren(ElementVisitor visitor) { @@ -1985,7 +1985,7 @@ class KeepAlive extends ParentDataWidget { @override void applyParentData(RenderObject renderObject) { assert(renderObject.parentData is KeepAliveParentDataMixin); - final KeepAliveParentDataMixin parentData = renderObject.parentData; + final KeepAliveParentDataMixin parentData = renderObject.parentData as KeepAliveParentDataMixin; if (parentData.keepAlive != keepAlive) { parentData.keepAlive = keepAlive; final AbstractNode targetParent = renderObject.parent; diff --git a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart index b8a22c9a27..30467ff099 100644 --- a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart @@ -173,10 +173,10 @@ class _SliverPersistentHeaderElement extends RenderObjectElement { _SliverPersistentHeaderElement(_SliverPersistentHeaderRenderObjectWidget widget) : super(widget); @override - _SliverPersistentHeaderRenderObjectWidget get widget => super.widget; + _SliverPersistentHeaderRenderObjectWidget get widget => super.widget as _SliverPersistentHeaderRenderObjectWidget; @override - _RenderSliverPersistentHeaderForWidgetsMixin get renderObject => super.renderObject; + _RenderSliverPersistentHeaderForWidgetsMixin get renderObject => super.renderObject as _RenderSliverPersistentHeaderForWidgetsMixin; @override void mount(Element parent, dynamic newSlot) { @@ -230,7 +230,7 @@ class _SliverPersistentHeaderElement extends RenderObjectElement { } @override - void insertChildRenderObject(covariant RenderObject child, dynamic slot) { + void insertChildRenderObject(covariant RenderBox child, dynamic slot) { assert(renderObject.debugValidateChild(child)); renderObject.child = child; } diff --git a/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart b/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart index bbd84512d9..9afa8df265 100644 --- a/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart +++ b/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart @@ -52,7 +52,7 @@ class SliverPrototypeExtentList extends SliverMultiBoxAdaptorWidget { @override _RenderSliverPrototypeExtentList createRenderObject(BuildContext context) { - final _SliverPrototypeExtentListElement element = context; + final _SliverPrototypeExtentListElement element = context as _SliverPrototypeExtentListElement; return _RenderSliverPrototypeExtentList(childManager: element); } @@ -64,10 +64,10 @@ class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement { _SliverPrototypeExtentListElement(SliverPrototypeExtentList widget) : super(widget); @override - SliverPrototypeExtentList get widget => super.widget; + SliverPrototypeExtentList get widget => super.widget as SliverPrototypeExtentList; @override - _RenderSliverPrototypeExtentList get renderObject => super.renderObject; + _RenderSliverPrototypeExtentList get renderObject => super.renderObject as _RenderSliverPrototypeExtentList; Element _prototype; static final Object _prototypeSlot = Object(); @@ -76,9 +76,9 @@ class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement { void insertChildRenderObject(covariant RenderObject child, covariant dynamic slot) { if (slot == _prototypeSlot) { assert(child is RenderBox); - renderObject.child = child; + renderObject.child = child as RenderBox; } else { - super.insertChildRenderObject(child, slot); + super.insertChildRenderObject(child, slot as int); } } @@ -93,7 +93,7 @@ class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement { if (slot == _prototypeSlot) assert(false); // There's only one prototype child so it cannot be moved. else - super.moveChildRenderObject(child, slot); + super.moveChildRenderObject(child, slot as int); } @override diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index 8a2a468cff..3eec4b717d 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -240,10 +240,10 @@ class _TableElement extends RenderObjectElement { _TableElement(Table widget) : super(widget); @override - Table get widget => super.widget; + Table get widget => super.widget as Table; @override - RenderTable get renderObject => super.renderObject; + RenderTable get renderObject => super.renderObject as RenderTable; // This class ignores the child's slot entirely. // Instead of doing incremental updates to the child list, it replaces the entire list each frame. @@ -276,7 +276,7 @@ class _TableElement extends RenderObjectElement { @override void removeChildRenderObject(RenderObject child) { - final TableCellParentData childParentData = child.parentData; + final TableCellParentData childParentData = child.parentData as TableCellParentData; renderObject.setChild(childParentData.x, childParentData.y, null); } @@ -326,7 +326,7 @@ class _TableElement extends RenderObjectElement { _children.isNotEmpty ? _children[0].children.length : 0, _children.expand((_TableElementRow row) { return row.children.map((Element child) { - final RenderBox box = child.renderObject; + final RenderBox box = child.renderObject as RenderBox; return box; }); }).toList(), @@ -367,7 +367,7 @@ class TableCell extends ParentDataWidget { @override void applyParentData(RenderObject renderObject) { - final TableCellParentData parentData = renderObject.parentData; + final TableCellParentData parentData = renderObject.parentData as TableCellParentData; if (parentData.verticalAlignment != verticalAlignment) { parentData.verticalAlignment = verticalAlignment; final AbstractNode targetParent = renderObject.parent; diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index 0640c8e431..3afbbfcfc4 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -435,7 +435,7 @@ class Text extends StatelessWidget { text: TextSpan( style: effectiveTextStyle, text: data, - children: textSpan != null ? [textSpan] : null, + children: textSpan != null ? [textSpan] : null, ), ); if (semanticsLabel != null) { diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index e9d9d28e83..8a0cb9729b 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -265,7 +265,7 @@ class SlideTransition extends AnimatedWidget { /// If the current value of the position animation is `(dx, dy)`, the child /// will be translated horizontally by `width * dx` and vertically by /// `height * dy`, after applying the [textDirection] if available. - Animation get position => listenable; + Animation get position => listenable as Animation; /// The direction to use for the x offset described by the [position]. /// @@ -337,7 +337,7 @@ class ScaleTransition extends AnimatedWidget { /// /// If the current value of the scale animation is v, the child will be /// painted v times its normal size. - Animation get scale => listenable; + Animation get scale => listenable as Animation; /// The alignment of the origin of the coordinate system in which the scale /// takes place, relative to the size of the box. @@ -391,7 +391,7 @@ class RotationTransition extends AnimatedWidget { /// /// If the current value of the turns animation is v, the child will be /// rotated v * 2 * pi radians before being painted. - Animation get turns => listenable; + Animation get turns => listenable as Animation; /// The alignment of the origin of the coordinate system around which the /// rotation occurs, relative to the size of the box. @@ -473,7 +473,7 @@ class SizeTransition extends AnimatedWidget { /// /// If the value of [sizeFactor] is less than one, the child will be clipped /// in the appropriate axis. - Animation get sizeFactor => listenable; + Animation get sizeFactor => listenable as Animation; /// Describes how to align the child along the axis that [sizeFactor] is /// modifying. @@ -635,7 +635,7 @@ class PositionedTransition extends AnimatedWidget { super(key: key, listenable: rect); /// The animation that controls the child's size and position. - Animation get rect => listenable; + Animation get rect => listenable as Animation; /// The widget below this widget in the tree. /// @@ -692,7 +692,7 @@ class RelativePositionedTransition extends AnimatedWidget { /// The animation that controls the child's size and position. /// /// See also [size]. - Animation get rect => listenable; + Animation get rect => listenable as Animation; /// The [Positioned] widget's offsets are relative to a box of this /// size whose origin is 0,0. @@ -806,7 +806,7 @@ class AlignTransition extends AnimatedWidget { super(key: key, listenable: alignment); /// The animation that controls the child's alignment. - Animation get alignment => listenable; + Animation get alignment => listenable as Animation; /// If non-null, the child's width factor, see [Align.widthFactor]. final double widthFactor; @@ -855,7 +855,7 @@ class DefaultTextStyleTransition extends AnimatedWidget { super(key: key, listenable: style); /// The animation that controls the descendants' text style. - Animation get style => listenable; + Animation get style => listenable as Animation; /// How the text should be aligned horizontally. final TextAlign textAlign; diff --git a/packages/flutter/lib/src/widgets/tween_animation_builder.dart b/packages/flutter/lib/src/widgets/tween_animation_builder.dart index a4d1e9b481..d67597675c 100644 --- a/packages/flutter/lib/src/widgets/tween_animation_builder.dart +++ b/packages/flutter/lib/src/widgets/tween_animation_builder.dart @@ -215,7 +215,7 @@ class _TweenAnimationBuilderState extends AnimatedWidgetBaseState; } @override diff --git a/packages/flutter/lib/src/widgets/unique_widget.dart b/packages/flutter/lib/src/widgets/unique_widget.dart index 42aeb9de35..d2d283fee7 100644 --- a/packages/flutter/lib/src/widgets/unique_widget.dart +++ b/packages/flutter/lib/src/widgets/unique_widget.dart @@ -34,7 +34,7 @@ abstract class UniqueWidget> extends StatefulWid /// /// Might be null if the widget is not currently in the tree. T get currentState { - final GlobalKey globalKey = key; + final GlobalKey globalKey = key as GlobalKey; return globalKey.currentState; } } diff --git a/packages/flutter/lib/src/widgets/viewport.dart b/packages/flutter/lib/src/widgets/viewport.dart index d884d7a9fc..2623ad2a01 100644 --- a/packages/flutter/lib/src/widgets/viewport.dart +++ b/packages/flutter/lib/src/widgets/viewport.dart @@ -186,10 +186,10 @@ class _ViewportElement extends MultiChildRenderObjectElement { _ViewportElement(Viewport widget) : super(widget); @override - Viewport get widget => super.widget; + Viewport get widget => super.widget as Viewport; @override - RenderViewport get renderObject => super.renderObject; + RenderViewport get renderObject => super.renderObject as RenderViewport; @override void mount(Element parent, dynamic newSlot) { @@ -208,9 +208,9 @@ class _ViewportElement extends MultiChildRenderObjectElement { if (widget.center != null) { renderObject.center = children.singleWhere( (Element element) => element.widget.key == widget.center - ).renderObject; + ).renderObject as RenderSliver; } else if (children.isNotEmpty) { - renderObject.center = children.first.renderObject; + renderObject.center = children.first.renderObject as RenderSliver; } else { renderObject.center = null; } @@ -219,7 +219,7 @@ class _ViewportElement extends MultiChildRenderObjectElement { @override void debugVisitOnstageChildren(ElementVisitor visitor) { children.where((Element e) { - final RenderSliver renderSliver = e.renderObject; + final RenderSliver renderSliver = e.renderObject as RenderSliver; return renderSliver.geometry.visible; }).forEach(visitor); } diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index eb7adcd430..cff08a15a8 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -544,7 +544,7 @@ class _ScreenshotPaintingContext extends PaintingContext { }) { RenderObject repaintBoundary = renderObject; while (repaintBoundary != null && !repaintBoundary.isRepaintBoundary) { - repaintBoundary = repaintBoundary.parent; + repaintBoundary = repaintBoundary.parent as RenderObject; } assert(repaintBoundary != null); final _ScreenshotData data = _ScreenshotData(target: renderObject); @@ -560,7 +560,7 @@ class _ScreenshotPaintingContext extends PaintingContext { // want to capture debugPaint information as well. data.containerLayer.append(_ProxyLayer(repaintBoundary.debugLayer)); data.foundTarget = true; - final OffsetLayer offsetLayer = repaintBoundary.debugLayer; + final OffsetLayer offsetLayer = repaintBoundary.debugLayer as OffsetLayer; data.screenshotOffset = offsetLayer.offset; } else { // Repaint everything under the repaint boundary. @@ -1288,10 +1288,10 @@ mixin WidgetInspectorService { /// The local project directories are used to distinguish widgets created by /// the local project over widgets created from inside the framework. @protected - void setPubRootDirectories(List pubRootDirectories) { - _pubRootDirectories = pubRootDirectories.map( - (Object directory) => Uri.parse(directory).path, - ).toList(); + void setPubRootDirectories(List pubRootDirectories) { + _pubRootDirectories = pubRootDirectories + .map((String directory) => Uri.parse(directory).path) + .toList(); } /// Set the [WidgetInspector] selection to the object matching the specified @@ -1326,7 +1326,7 @@ mixin WidgetInspectorService { if (object == selection.current) { return false; } - selection.current = object; + selection.current = object as RenderObject; developer.inspect(selection.current); } if (selectionChangedCallback != null) { @@ -1408,7 +1408,7 @@ mixin WidgetInspectorService { final List chain = []; while (renderObject != null) { chain.add(renderObject); - renderObject = renderObject.parent; + renderObject = renderObject.parent as RenderObject; } return _followDiagnosticableChain(chain.reversed.toList()); } @@ -1475,7 +1475,7 @@ mixin WidgetInspectorService { } List> _nodesToJson( - Iterable nodes, + List nodes, InspectorSerializationDelegate delegate, { @required DiagnosticsNode parent, }) { @@ -1490,7 +1490,7 @@ mixin WidgetInspectorService { } List _getProperties(String diagnosticsNodeId, String groupName) { - final DiagnosticsNode node = toObject(diagnosticsNodeId); + final DiagnosticsNode node = toObject(diagnosticsNodeId) as DiagnosticsNode; return _nodesToJson(node == null ? const [] : node.getProperties(), InspectorSerializationDelegate(groupName: groupName, service: this), parent: node); } @@ -1501,7 +1501,7 @@ mixin WidgetInspectorService { } List _getChildren(String diagnosticsNodeId, String groupName) { - final DiagnosticsNode node = toObject(diagnosticsNodeId); + final DiagnosticsNode node = toObject(diagnosticsNodeId) as DiagnosticsNode; final InspectorSerializationDelegate delegate = InspectorSerializationDelegate(groupName: groupName, service: this); return _nodesToJson(node == null ? const [] : _getChildrenFiltered(node, delegate), delegate, parent: node); } @@ -1523,7 +1523,7 @@ mixin WidgetInspectorService { } List _getChildrenSummaryTree(String diagnosticsNodeId, String groupName) { - final DiagnosticsNode node = toObject(diagnosticsNodeId); + final DiagnosticsNode node = toObject(diagnosticsNodeId) as DiagnosticsNode; final InspectorSerializationDelegate delegate = InspectorSerializationDelegate(groupName: groupName, summaryTree: true, service: this); return _nodesToJson(node == null ? const [] : _getChildrenFiltered(node, delegate), delegate, parent: node); } @@ -1539,7 +1539,7 @@ mixin WidgetInspectorService { } List _getChildrenDetailsSubtree(String diagnosticsNodeId, String groupName) { - final DiagnosticsNode node = toObject(diagnosticsNodeId); + final DiagnosticsNode node = toObject(diagnosticsNodeId) as DiagnosticsNode; // With this value of minDepth we only expand one extra level of important nodes. final InspectorSerializationDelegate delegate = InspectorSerializationDelegate(groupName: groupName, subtreeDepth: 1, includeProperties: true, service: this); return _nodesToJson(node == null ? const [] : _getChildrenFiltered(node, delegate), delegate, parent: node); @@ -1641,7 +1641,7 @@ mixin WidgetInspectorService { String groupName, int subtreeDepth, ) { - final DiagnosticsNode root = toObject(id); + final DiagnosticsNode root = toObject(id) as DiagnosticsNode; if (root == null) { return null; } @@ -1669,7 +1669,7 @@ mixin WidgetInspectorService { } Map _getSelectedRenderObject(String previousSelectionId, String groupName) { - final DiagnosticsNode previousSelection = toObject(previousSelectionId); + final DiagnosticsNode previousSelection = toObject(previousSelectionId) as DiagnosticsNode; final RenderObject current = selection?.current; return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), InspectorSerializationDelegate(groupName: groupName, service: this)); } @@ -1708,7 +1708,7 @@ mixin WidgetInspectorService { if (object is! Element && object is! RenderObject) { return null; } - final RenderObject renderObject = object is Element ? object.renderObject : object; + final RenderObject renderObject = object is Element ? object.renderObject : (object as RenderObject); if (renderObject == null || !renderObject.attached) { return null; } @@ -1756,7 +1756,7 @@ mixin WidgetInspectorService { } Map _getSelectedWidget(String previousSelectionId, String groupName) { - final DiagnosticsNode previousSelection = toObject(previousSelectionId); + final DiagnosticsNode previousSelection = toObject(previousSelectionId) as DiagnosticsNode; final Element current = selection?.currentElement; return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), InspectorSerializationDelegate(groupName: groupName, service: this)); } @@ -1777,7 +1777,7 @@ mixin WidgetInspectorService { if (!isWidgetCreationTracked()) { return _getSelectedWidget(previousSelectionId, groupName); } - final DiagnosticsNode previousSelection = toObject(previousSelectionId); + final DiagnosticsNode previousSelection = toObject(previousSelectionId) as DiagnosticsNode; Element current = selection?.currentElement; if (current != null && !_isValueCreatedByLocalProject(current)) { Element firstLocal; @@ -1843,7 +1843,7 @@ mixin WidgetInspectorService { void _onPaint(RenderObject renderObject) { try { - final Element element = renderObject.debugCreator?.element; + final Element element = renderObject.debugCreator?.element as Element; if (element is! RenderObjectElement) { // This branch should not hit as long as all RenderObjects were created // by Widgets. It is possible there might be some render objects @@ -1958,7 +1958,7 @@ class _ElementLocationStatsTracker { if (widget is! _HasCreationLocation) { return; } - final _HasCreationLocation creationLocationSource = widget; + final _HasCreationLocation creationLocationSource = widget as _HasCreationLocation; final _Location location = creationLocationSource._location; final int id = _toLocationId(location); @@ -2161,7 +2161,7 @@ class _WidgetInspectorState extends State if (diagnostics.style == DiagnosticsTreeStyle.offstage || diagnostics.value is! RenderObject) continue; - final RenderObject child = diagnostics.value; + final RenderObject child = diagnostics.value as RenderObject; final Rect paintClip = object.describeApproximatePaintClip(child); if (paintClip != null && !paintClip.contains(localPosition)) continue; @@ -2215,7 +2215,7 @@ class _WidgetInspectorState extends State if (!isSelectMode) return; - final RenderIgnorePointer ignorePointer = _ignorePointerKey.currentContext.findRenderObject(); + final RenderIgnorePointer ignorePointer = _ignorePointerKey.currentContext.findRenderObject() as RenderIgnorePointer; final RenderObject userRender = ignorePointer.child; final List selected = hitTest(position, userRender); @@ -2338,7 +2338,7 @@ class InspectorSelection { set current(RenderObject value) { if (_current != value) { _current = value; - _currentElement = value.debugCreator.element; + _currentElement = value.debugCreator.element as Element; } } @@ -2359,7 +2359,7 @@ class InspectorSelection { void _computeCurrent() { if (_index < candidates.length) { _current = candidates[index]; - _currentElement = _current.debugCreator.element; + _currentElement = _current.debugCreator.element as Element; } else { _current = null; _currentElement = null; @@ -2438,8 +2438,9 @@ class _TransformedRect { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - final _TransformedRect typedOther = other; - return rect == typedOther.rect && transform == typedOther.transform; + return other is _TransformedRect + && other.rect == rect + && other.transform == transform; } @override @@ -2469,12 +2470,11 @@ class _InspectorOverlayRenderState { bool operator ==(dynamic other) { if (other.runtimeType != runtimeType) return false; - - final _InspectorOverlayRenderState typedOther = other; - return overlayRect == typedOther.overlayRect - && selected == typedOther.selected - && listEquals<_TransformedRect>(candidates, typedOther.candidates) - && tooltip == typedOther.tooltip; + return other is _InspectorOverlayRenderState + && other.overlayRect == overlayRect + && other.selected == selected + && listEquals<_TransformedRect>(other.candidates, candidates) + && other.tooltip == tooltip; } @override @@ -2616,7 +2616,7 @@ class _InspectorOverlayLayer extends Layer { ) { canvas.save(); final double maxWidth = size.width - 2 * (_kScreenEdgeMargin + _kTooltipPadding); - final TextSpan textSpan = _textPainter?.text; + final TextSpan textSpan = _textPainter?.text as TextSpan; if (_textPainter == null || textSpan.text != message || _textPainterMaxWidth != maxWidth) { _textPainterMaxWidth = maxWidth; _textPainter = TextPainter() @@ -2789,7 +2789,7 @@ Iterable transformDebugCreator(Iterable proper Iterable _parseDiagnosticsNode(DiagnosticsNode node) { if (!_isDebugCreator(node)) return null; - final DebugCreator debugCreator = node.value; + final DebugCreator debugCreator = node.value as DebugCreator; final Element element = debugCreator.element; return _describeRelevantUserCode(element); } diff --git a/packages/flutter/lib/src/widgets/widget_span.dart b/packages/flutter/lib/src/widgets/widget_span.dart index 1e4cb6a7c6..65a283ef8f 100644 --- a/packages/flutter/lib/src/widgets/widget_span.dart +++ b/packages/flutter/lib/src/widgets/widget_span.dart @@ -148,7 +148,7 @@ class WidgetSpan extends PlaceholderSpan { return RenderComparison.layout; if ((style == null) != (other.style == null)) return RenderComparison.layout; - final WidgetSpan typedOther = other; + final WidgetSpan typedOther = other as WidgetSpan; if (child != typedOther.child || alignment != typedOther.alignment) { return RenderComparison.layout; } @@ -171,10 +171,10 @@ class WidgetSpan extends PlaceholderSpan { return false; if (super != other) return false; - final WidgetSpan typedOther = other; - return typedOther.child == child - && typedOther.alignment == alignment - && typedOther.baseline == baseline; + return other is WidgetSpan + && other.child == child + && other.alignment == alignment + && other.baseline == baseline; } @override diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index 76f4f4a545..3b468da47b 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -810,7 +810,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { final Element elementB = find.text('b').evaluate().first; service.disposeAllGroups(); - service.setPubRootDirectories([]); + service.setPubRootDirectories([]); service.setSelection(elementA, 'my-group'); final Map jsonA = json.decode(service.getSelectedWidget(null, 'my-group')); final Map creationLocationA = jsonA['creationLocation']; @@ -885,7 +885,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // directory. pubRootTest = '/' + segments.take(segments.length - 2).join('/'); - service.setPubRootDirectories([pubRootTest]); + service.setPubRootDirectories([pubRootTest]); } final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); builder.add(StringProperty('dummy1', 'value')); @@ -948,7 +948,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // directory. pubRootTest = '/' + segments.take(segments.length - 2).join('/'); - service.setPubRootDirectories([pubRootTest]); + service.setPubRootDirectories([pubRootTest]); } final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); builder.add(StringProperty('dummy1', 'value')); @@ -995,7 +995,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { final Element elementA = find.text('a').evaluate().first; service.disposeAllGroups(); - service.setPubRootDirectories([]); + service.setPubRootDirectories([]); service.setSelection(elementA, 'my-group'); Map jsonObject = json.decode(service.getSelectedWidget(null, 'my-group')); Map creationLocation = jsonObject['creationLocation']; @@ -1007,21 +1007,21 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // Strip a couple subdirectories away to generate a plausible pub root // directory. final String pubRootTest = '/' + segments.take(segments.length - 2).join('/'); - service.setPubRootDirectories([pubRootTest]); + service.setPubRootDirectories([pubRootTest]); service.setSelection(elementA, 'my-group'); expect(json.decode(service.getSelectedWidget(null, 'my-group')), contains('createdByLocalProject')); - service.setPubRootDirectories(['/invalid/$pubRootTest']); + service.setPubRootDirectories(['/invalid/$pubRootTest']); expect(json.decode(service.getSelectedWidget(null, 'my-group')), isNot(contains('createdByLocalProject'))); - service.setPubRootDirectories(['file://$pubRootTest']); + service.setPubRootDirectories(['file://$pubRootTest']); expect(json.decode(service.getSelectedWidget(null, 'my-group')), contains('createdByLocalProject')); - service.setPubRootDirectories(['$pubRootTest/different']); + service.setPubRootDirectories(['$pubRootTest/different']); expect(json.decode(service.getSelectedWidget(null, 'my-group')), isNot(contains('createdByLocalProject'))); - service.setPubRootDirectories([ + service.setPubRootDirectories([ '/invalid/$pubRootTest', pubRootTest, ]); @@ -1034,7 +1034,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { matching: find.byType(RichText), ).evaluate().first; service.setSelection(richText, 'my-group'); - service.setPubRootDirectories([pubRootTest]); + service.setPubRootDirectories([pubRootTest]); jsonObject = json.decode(service.getSelectedWidget(null, 'my-group')); expect(jsonObject, isNot(contains('createdByLocalProject'))); creationLocation = jsonObject['creationLocation']; @@ -1046,12 +1046,12 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // Strip off /src/widgets/text.dart. final String pubRootFramework = '/' + pathSegmentsFramework.take(pathSegmentsFramework.length - 3).join('/'); - service.setPubRootDirectories([pubRootFramework]); + service.setPubRootDirectories([pubRootFramework]); expect(json.decode(service.getSelectedWidget(null, 'my-group')), contains('createdByLocalProject')); service.setSelection(elementA, 'my-group'); expect(json.decode(service.getSelectedWidget(null, 'my-group')), isNot(contains('createdByLocalProject'))); - service.setPubRootDirectories([pubRootFramework, pubRootTest]); + service.setPubRootDirectories([pubRootFramework, pubRootTest]); service.setSelection(elementA, 'my-group'); expect(json.decode(service.getSelectedWidget(null, 'my-group')), contains('createdByLocalProject')); service.setSelection(richText, 'my-group'); @@ -1609,7 +1609,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { matching: find.byType(RichText), ).evaluate().first; service.setSelection(richText, 'my-group'); - service.setPubRootDirectories([pubRootTest]); + service.setPubRootDirectories([pubRootTest]); jsonObject = json.decode(service.getSelectedWidget(null, 'my-group')); expect(jsonObject, isNot(contains('createdByLocalProject'))); creationLocation = jsonObject['creationLocation'];