enable lint cast_nullable_to_non_nullable (#67629)

This commit is contained in:
Alexandre Ardhuin 2020-10-08 21:05:43 +02:00 committed by GitHub
parent 684449a841
commit 4acc790252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 280 additions and 287 deletions

View File

@ -95,6 +95,7 @@ linter:
- camel_case_types - camel_case_types
- cancel_subscriptions - cancel_subscriptions
# - cascade_invocations # not yet tested # - cascade_invocations # not yet tested
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough # - close_sinks # not reliable enough
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765 # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204 # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204

View File

@ -704,13 +704,13 @@ class _RenderCupertinoAlert extends RenderBox {
// Set the position of the actions box to sit at the bottom of the alert. // Set the position of the actions box to sit at the bottom of the alert.
// The content box defaults to the top left, which is where we want it. // The content box defaults to the top left, which is where we want it.
assert(actionsSection!.parentData is MultiChildLayoutParentData); assert(actionsSection!.parentData is MultiChildLayoutParentData);
final MultiChildLayoutParentData actionParentData = actionsSection!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData actionParentData = actionsSection!.parentData! as MultiChildLayoutParentData;
actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness);
} }
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
final MultiChildLayoutParentData contentParentData = contentSection!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData contentParentData = contentSection!.parentData! as MultiChildLayoutParentData;
contentSection!.paint(context, offset + contentParentData.offset); contentSection!.paint(context, offset + contentParentData.offset);
final bool hasDivider = contentSection!.size.height > 0.0 && actionsSection!.size.height > 0.0; final bool hasDivider = contentSection!.size.height > 0.0 && actionsSection!.size.height > 0.0;
@ -718,7 +718,7 @@ class _RenderCupertinoAlert extends RenderBox {
_paintDividerBetweenContentAndActions(context.canvas, offset); _paintDividerBetweenContentAndActions(context.canvas, offset);
} }
final MultiChildLayoutParentData actionsParentData = actionsSection!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData actionsParentData = actionsSection!.parentData! as MultiChildLayoutParentData;
actionsSection!.paint(context, offset + actionsParentData.offset); actionsSection!.paint(context, offset + actionsParentData.offset);
} }
@ -736,8 +736,8 @@ class _RenderCupertinoAlert extends RenderBox {
@override @override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
final MultiChildLayoutParentData contentSectionParentData = contentSection!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData contentSectionParentData = contentSection!.parentData! as MultiChildLayoutParentData;
final MultiChildLayoutParentData actionsSectionParentData = actionsSection!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData actionsSectionParentData = actionsSection!.parentData! as MultiChildLayoutParentData;
return result.addWithPaintOffset( return result.addWithPaintOffset(
offset: contentSectionParentData.offset, offset: contentSectionParentData.offset,
position: position, position: position,
@ -977,7 +977,7 @@ class _ActionButtonParentDataWidget extends ParentDataWidget<_ActionButtonParent
@override @override
void applyParentData(RenderObject renderObject) { void applyParentData(RenderObject renderObject) {
assert(renderObject.parentData is _ActionButtonParentData); assert(renderObject.parentData is _ActionButtonParentData);
final _ActionButtonParentData parentData = renderObject.parentData as _ActionButtonParentData; final _ActionButtonParentData parentData = renderObject.parentData! as _ActionButtonParentData;
if (parentData.isPressed != isPressed) { if (parentData.isPressed != isPressed) {
parentData.isPressed = isPressed; parentData.isPressed = isPressed;
@ -1232,7 +1232,7 @@ class _RenderCupertinoAlertActions extends RenderBox
); );
assert(child.parentData is MultiChildLayoutParentData); assert(child.parentData is MultiChildLayoutParentData);
final MultiChildLayoutParentData parentData = child.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData parentData = child.parentData! as MultiChildLayoutParentData;
parentData.offset = Offset(0.0, verticalOffset); parentData.offset = Offset(0.0, verticalOffset);
verticalOffset += child.size.height; verticalOffset += child.size.height;
@ -1274,13 +1274,13 @@ class _RenderCupertinoAlertActions extends RenderBox
RenderBox? prevChild; RenderBox? prevChild;
while (child != null) { while (child != null) {
assert(child.parentData is _ActionButtonParentData); assert(child.parentData is _ActionButtonParentData);
final _ActionButtonParentData currentButtonParentData = child.parentData as _ActionButtonParentData; final _ActionButtonParentData currentButtonParentData = child.parentData! as _ActionButtonParentData;
final bool isButtonPressed = currentButtonParentData.isPressed; final bool isButtonPressed = currentButtonParentData.isPressed;
bool isPrevButtonPressed = false; bool isPrevButtonPressed = false;
if (prevChild != null) { if (prevChild != null) {
assert(prevChild.parentData is _ActionButtonParentData); assert(prevChild.parentData is _ActionButtonParentData);
final _ActionButtonParentData previousButtonParentData = prevChild.parentData as _ActionButtonParentData; final _ActionButtonParentData previousButtonParentData = prevChild.parentData! as _ActionButtonParentData;
isPrevButtonPressed = previousButtonParentData.isPressed; isPrevButtonPressed = previousButtonParentData.isPressed;
} }
@ -1330,7 +1330,7 @@ class _RenderCupertinoAlertActions extends RenderBox
void _drawButtons(PaintingContext context, Offset offset) { void _drawButtons(PaintingContext context, Offset offset) {
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
final MultiChildLayoutParentData childParentData = child.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData childParentData = child.parentData! as MultiChildLayoutParentData;
context.paintChild(child, childParentData.offset + offset); context.paintChild(child, childParentData.offset + offset);
child = childAfter(child); child = childAfter(child);
} }

View File

@ -40,7 +40,7 @@ typedef _ContextMenuPreviewBuilderChildless = Widget Function(
// paintBounds in global coordinates. // paintBounds in global coordinates.
Rect _getRect(GlobalKey globalKey) { Rect _getRect(GlobalKey globalKey) {
assert(globalKey.currentContext != null); assert(globalKey.currentContext != null);
final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject() as RenderBox; final RenderBox renderBoxContainer = globalKey.currentContext!.findRenderObject()! as RenderBox;
final Offset containerOffset = renderBoxContainer.localToGlobal( final Offset containerOffset = renderBoxContainer.localToGlobal(
renderBoxContainer.paintBounds.topLeft, renderBoxContainer.paintBounds.topLeft,
); );

View File

@ -714,7 +714,7 @@ class _RenderCupertinoDialog extends RenderBox {
// Set the position of the actions box to sit at the bottom of the dialog. // Set the position of the actions box to sit at the bottom of the dialog.
// The content box defaults to the top left, which is where we want it. // The content box defaults to the top left, which is where we want it.
assert(actionsSection!.parentData is BoxParentData); assert(actionsSection!.parentData is BoxParentData);
final BoxParentData actionParentData = actionsSection!.parentData as BoxParentData; final BoxParentData actionParentData = actionsSection!.parentData! as BoxParentData;
actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness);
} }
@ -776,13 +776,13 @@ class _RenderCupertinoDialog extends RenderBox {
// Set the position of the actions box to sit at the bottom of the dialog. // Set the position of the actions box to sit at the bottom of the dialog.
// The content box defaults to the top left, which is where we want it. // The content box defaults to the top left, which is where we want it.
assert(actionsSection!.parentData is BoxParentData); assert(actionsSection!.parentData is BoxParentData);
final BoxParentData actionParentData = actionsSection!.parentData as BoxParentData; final BoxParentData actionParentData = actionsSection!.parentData! as BoxParentData;
actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness);
} }
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
final BoxParentData contentParentData = contentSection!.parentData as BoxParentData; final BoxParentData contentParentData = contentSection!.parentData! as BoxParentData;
contentSection!.paint(context, offset + contentParentData.offset); contentSection!.paint(context, offset + contentParentData.offset);
final bool hasDivider = contentSection!.size.height > 0.0 && actionsSection!.size.height > 0.0; final bool hasDivider = contentSection!.size.height > 0.0 && actionsSection!.size.height > 0.0;
@ -790,7 +790,7 @@ class _RenderCupertinoDialog extends RenderBox {
_paintDividerBetweenContentAndActions(context.canvas, offset); _paintDividerBetweenContentAndActions(context.canvas, offset);
} }
final BoxParentData actionsParentData = actionsSection!.parentData as BoxParentData; final BoxParentData actionsParentData = actionsSection!.parentData! as BoxParentData;
actionsSection!.paint(context, offset + actionsParentData.offset); actionsSection!.paint(context, offset + actionsParentData.offset);
} }
@ -808,8 +808,8 @@ class _RenderCupertinoDialog extends RenderBox {
@override @override
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
final BoxParentData contentSectionParentData = contentSection!.parentData as BoxParentData; final BoxParentData contentSectionParentData = contentSection!.parentData! as BoxParentData;
final BoxParentData actionsSectionParentData = actionsSection!.parentData as BoxParentData; final BoxParentData actionsSectionParentData = actionsSection!.parentData! as BoxParentData;
return result.addWithPaintOffset( return result.addWithPaintOffset(
offset: contentSectionParentData.offset, offset: contentSectionParentData.offset,
position: position, position: position,
@ -1041,7 +1041,7 @@ class _ActionButtonParentDataWidget extends ParentDataWidget<_ActionButtonParent
@override @override
void applyParentData(RenderObject renderObject) { void applyParentData(RenderObject renderObject) {
assert(renderObject.parentData is _ActionButtonParentData); assert(renderObject.parentData is _ActionButtonParentData);
final _ActionButtonParentData parentData = renderObject.parentData as _ActionButtonParentData; final _ActionButtonParentData parentData = renderObject.parentData! as _ActionButtonParentData;
if (parentData.isPressed != isPressed) { if (parentData.isPressed != isPressed) {
parentData.isPressed = isPressed; parentData.isPressed = isPressed;
@ -1396,7 +1396,7 @@ class _RenderCupertinoDialogActions extends RenderBox
RenderBox? currentChild = firstChild; RenderBox? currentChild = firstChild;
while (currentChild != null) { while (currentChild != null) {
assert(currentChild.parentData is _ActionButtonParentData); assert(currentChild.parentData is _ActionButtonParentData);
final _ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData; final _ActionButtonParentData parentData = currentChild.parentData! as _ActionButtonParentData;
if (parentData.isPressed) { if (parentData.isPressed) {
yield currentChild; yield currentChild;
} }
@ -1408,7 +1408,7 @@ class _RenderCupertinoDialogActions extends RenderBox
RenderBox? currentChild = firstChild; RenderBox? currentChild = firstChild;
while (currentChild != null) { while (currentChild != null) {
assert(currentChild.parentData is _ActionButtonParentData); assert(currentChild.parentData is _ActionButtonParentData);
final _ActionButtonParentData parentData = currentChild.parentData as _ActionButtonParentData; final _ActionButtonParentData parentData = currentChild.parentData! as _ActionButtonParentData;
if (parentData.isPressed) { if (parentData.isPressed) {
return true; return true;
} }
@ -1582,7 +1582,7 @@ class _RenderCupertinoDialogActions extends RenderBox
// The 2nd button needs to be offset to the right. // The 2nd button needs to be offset to the right.
assert(lastChild!.parentData is MultiChildLayoutParentData); assert(lastChild!.parentData is MultiChildLayoutParentData);
final MultiChildLayoutParentData secondButtonParentData = lastChild!.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData secondButtonParentData = lastChild!.parentData! as MultiChildLayoutParentData;
secondButtonParentData.offset = Offset(firstChild!.size.width + dividerThickness, 0.0); secondButtonParentData.offset = Offset(firstChild!.size.width + dividerThickness, 0.0);
// Calculate our size based on the button sizes. // Calculate our size based on the button sizes.
@ -1613,7 +1613,7 @@ class _RenderCupertinoDialogActions extends RenderBox
); );
assert(child.parentData is MultiChildLayoutParentData); assert(child.parentData is MultiChildLayoutParentData);
final MultiChildLayoutParentData parentData = child.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData parentData = child.parentData! as MultiChildLayoutParentData;
parentData.offset = Offset(0.0, verticalOffset); parentData.offset = Offset(0.0, verticalOffset);
verticalOffset += child.size.height; verticalOffset += child.size.height;
@ -1663,7 +1663,7 @@ class _RenderCupertinoDialogActions extends RenderBox
: Rect.zero; : Rect.zero;
final List<Rect> pressedButtonRects = _pressedButtons.map<Rect>((RenderBox pressedButton) { final List<Rect> pressedButtonRects = _pressedButtons.map<Rect>((RenderBox pressedButton) {
final MultiChildLayoutParentData buttonParentData = pressedButton.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData buttonParentData = pressedButton.parentData! as MultiChildLayoutParentData;
return Rect.fromLTWH( return Rect.fromLTWH(
offset.dx + buttonParentData.offset.dx, offset.dx + buttonParentData.offset.dx,
@ -1726,13 +1726,13 @@ class _RenderCupertinoDialogActions extends RenderBox
RenderBox? prevChild; RenderBox? prevChild;
while (child != null) { while (child != null) {
assert(child.parentData is _ActionButtonParentData); assert(child.parentData is _ActionButtonParentData);
final _ActionButtonParentData currentButtonParentData = child.parentData as _ActionButtonParentData; final _ActionButtonParentData currentButtonParentData = child.parentData! as _ActionButtonParentData;
final bool isButtonPressed = currentButtonParentData.isPressed; final bool isButtonPressed = currentButtonParentData.isPressed;
bool isPrevButtonPressed = false; bool isPrevButtonPressed = false;
if (prevChild != null) { if (prevChild != null) {
assert(prevChild.parentData is _ActionButtonParentData); assert(prevChild.parentData is _ActionButtonParentData);
final _ActionButtonParentData previousButtonParentData = prevChild.parentData as _ActionButtonParentData; final _ActionButtonParentData previousButtonParentData = prevChild.parentData! as _ActionButtonParentData;
isPrevButtonPressed = previousButtonParentData.isPressed; isPrevButtonPressed = previousButtonParentData.isPressed;
} }
@ -1782,7 +1782,7 @@ class _RenderCupertinoDialogActions extends RenderBox
void _drawButtons(PaintingContext context, Offset offset) { void _drawButtons(PaintingContext context, Offset offset) {
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
final MultiChildLayoutParentData childParentData = child.parentData as MultiChildLayoutParentData; final MultiChildLayoutParentData childParentData = child.parentData! as MultiChildLayoutParentData;
context.paintChild(child, childParentData.offset + offset); context.paintChild(child, childParentData.offset + offset);
child = childAfter(child); child = childAfter(child);
} }

View File

@ -1450,7 +1450,7 @@ class _BackLabel extends StatelessWidget {
if (specifiedPreviousTitle != null) { if (specifiedPreviousTitle != null) {
return _buildPreviousTitleWidget(context, specifiedPreviousTitle, null); return _buildPreviousTitleWidget(context, specifiedPreviousTitle, null);
} else if (route is CupertinoRouteTransitionMixin<dynamic> && !route!.isFirst) { } else if (route is CupertinoRouteTransitionMixin<dynamic> && !route!.isFirst) {
final CupertinoRouteTransitionMixin<dynamic> cupertinoRoute = route as CupertinoRouteTransitionMixin<dynamic>; final CupertinoRouteTransitionMixin<dynamic> cupertinoRoute = route! as CupertinoRouteTransitionMixin<dynamic>;
// There is no timing issue because the previousTitle Listenable changes // There is no timing issue because the previousTitle Listenable changes
// happen during route modifications before the ValueListenableBuilder // happen during route modifications before the ValueListenableBuilder
// is built. // is built.
@ -1499,7 +1499,7 @@ class _TransitionableNavigationBar extends StatelessWidget {
final Widget child; final Widget child;
RenderBox get renderBox { RenderBox get renderBox {
final RenderBox box = componentsKeys.navBarBoxKey.currentContext!.findRenderObject() as RenderBox; final RenderBox box = componentsKeys.navBarBoxKey.currentContext!.findRenderObject()! as RenderBox;
assert( assert(
box.attached, box.attached,
'_TransitionableNavigationBar.renderBox should be called when building ' '_TransitionableNavigationBar.renderBox should be called when building '
@ -1729,7 +1729,7 @@ class _NavigationBarComponentsTransition {
GlobalKey key, { GlobalKey key, {
required RenderBox from, required RenderBox from,
}) { }) {
final RenderBox componentBox = key.currentContext!.findRenderObject() as RenderBox; final RenderBox componentBox = key.currentContext!.findRenderObject()! as RenderBox;
assert(componentBox.attached); assert(componentBox.attached);
return RelativeRect.fromRect( return RelativeRect.fromRect(
@ -1756,8 +1756,8 @@ class _NavigationBarComponentsTransition {
}) { }) {
final RelativeRect fromRect = positionInTransitionBox(fromKey, from: fromNavBarBox); final RelativeRect fromRect = positionInTransitionBox(fromKey, from: fromNavBarBox);
final RenderBox fromBox = fromKey.currentContext!.findRenderObject() as RenderBox; final RenderBox fromBox = fromKey.currentContext!.findRenderObject()! as RenderBox;
final RenderBox toBox = toKey.currentContext!.findRenderObject() as RenderBox; final RenderBox toBox = toKey.currentContext!.findRenderObject()! as RenderBox;
// We move a box with the size of the 'from' render object such that its // We move a box with the size of the 'from' render object such that its
// upper left corner is at the upper left corner of the 'to' render object. // upper left corner is at the upper left corner of the 'to' render object.
@ -2038,7 +2038,7 @@ class _NavigationBarComponentsTransition {
// If it's the first page with a back chevron, shift in slightly from the // If it's the first page with a back chevron, shift in slightly from the
// right. // right.
if (bottomBackChevron == null) { if (bottomBackChevron == null) {
final RenderBox topBackChevronBox = topComponents.backChevronKey.currentContext!.findRenderObject() as RenderBox; final RenderBox topBackChevronBox = topComponents.backChevronKey.currentContext!.findRenderObject()! as RenderBox;
from = to.shift( from = to.shift(
Offset( Offset(
forwardDirection * topBackChevronBox.size.width * 2.0, forwardDirection * topBackChevronBox.size.width * 2.0,

View File

@ -551,8 +551,8 @@ bool _hitTestInteractive(GlobalKey customPaintKey, Offset offset) {
return false; return false;
} }
final CustomPaint customPaint = customPaintKey.currentContext!.widget as CustomPaint; final CustomPaint customPaint = customPaintKey.currentContext!.widget as CustomPaint;
final ScrollbarPainter painter = customPaint.foregroundPainter as ScrollbarPainter; final ScrollbarPainter painter = customPaint.foregroundPainter! as ScrollbarPainter;
final RenderBox renderBox = customPaintKey.currentContext!.findRenderObject() as RenderBox; final RenderBox renderBox = customPaintKey.currentContext!.findRenderObject()! as RenderBox;
final Offset localOffset = renderBox.globalToLocal(offset); final Offset localOffset = renderBox.globalToLocal(offset);
return painter.hitTestInteractive(localOffset); return painter.hitTestInteractive(localOffset);
} }

View File

@ -544,7 +544,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = firstChild; RenderBox? child = firstChild;
double minWidth = 0.0; double minWidth = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
final double childWidth = child.getMinIntrinsicWidth(height); final double childWidth = child.getMinIntrinsicWidth(height);
minWidth = math.max(minWidth, childWidth); minWidth = math.max(minWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -557,7 +557,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = firstChild; RenderBox? child = firstChild;
double maxWidth = 0.0; double maxWidth = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
final double childWidth = child.getMaxIntrinsicWidth(height); final double childWidth = child.getMaxIntrinsicWidth(height);
maxWidth = math.max(maxWidth, childWidth); maxWidth = math.max(maxWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -570,7 +570,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = firstChild; RenderBox? child = firstChild;
double minHeight = 0.0; double minHeight = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
final double childHeight = child.getMinIntrinsicHeight(width); final double childHeight = child.getMinIntrinsicHeight(width);
minHeight = math.max(minHeight, childHeight); minHeight = math.max(minHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -583,7 +583,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = firstChild; RenderBox? child = firstChild;
double maxHeight = 0.0; double maxHeight = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
final double childHeight = child.getMaxIntrinsicHeight(width); final double childHeight = child.getMaxIntrinsicHeight(width);
maxHeight = math.max(maxHeight, childHeight); maxHeight = math.max(maxHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -607,7 +607,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = leftChild; RenderBox? child = leftChild;
double start = 0.0; double start = 0.0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
final Offset childOffset = Offset(start, 0.0); final Offset childOffset = Offset(start, 0.0);
childParentData.offset = childOffset; childParentData.offset = childOffset;
final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height); final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height);
@ -692,7 +692,7 @@ class _RenderSegmentedControl<T> extends RenderBox
void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) { void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) {
assert(child != null); assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
context.canvas.drawRRect( context.canvas.drawRRect(
childParentData.surroundingRect!.shift(offset), childParentData.surroundingRect!.shift(offset),
@ -716,7 +716,7 @@ class _RenderSegmentedControl<T> extends RenderBox
assert(position != null); assert(position != null);
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = child.parentData as _SegmentedControlContainerBoxParentData; final _SegmentedControlContainerBoxParentData childParentData = child.parentData! as _SegmentedControlContainerBoxParentData;
if (childParentData.surroundingRect!.contains(position)) { if (childParentData.surroundingRect!.contains(position)) {
return result.addWithPaintOffset( return result.addWithPaintOffset(
offset: childParentData.offset, offset: childParentData.offset,

View File

@ -764,7 +764,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxMinChildWidth = 0; double maxMinChildWidth = 0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final double childWidth = child.getMinIntrinsicWidth(height); final double childWidth = child.getMinIntrinsicWidth(height);
maxMinChildWidth = math.max(maxMinChildWidth, childWidth); maxMinChildWidth = math.max(maxMinChildWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -778,7 +778,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxMaxChildWidth = 0; double maxMaxChildWidth = 0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final double childWidth = child.getMaxIntrinsicWidth(height); final double childWidth = child.getMaxIntrinsicWidth(height);
maxMaxChildWidth = math.max(maxMaxChildWidth, childWidth); maxMaxChildWidth = math.max(maxMaxChildWidth, childWidth);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -792,7 +792,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxMinChildHeight = 0; double maxMinChildHeight = 0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final double childHeight = child.getMinIntrinsicHeight(width); final double childHeight = child.getMinIntrinsicHeight(width);
maxMinChildHeight = math.max(maxMinChildHeight, childHeight); maxMinChildHeight = math.max(maxMinChildHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -806,7 +806,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double maxMaxChildHeight = 0; double maxMaxChildHeight = 0;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final double childHeight = child.getMaxIntrinsicHeight(width); final double childHeight = child.getMaxIntrinsicHeight(width);
maxMaxChildHeight = math.max(maxMaxChildHeight, childHeight); maxMaxChildHeight = math.max(maxMaxChildHeight, childHeight);
child = childParentData.nextSibling; child = childParentData.nextSibling;
@ -867,7 +867,7 @@ class _RenderSegmentedControl<T> extends RenderBox
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final Offset childOffset = Offset(start, 0); final Offset childOffset = Offset(start, 0);
childParentData.offset = childOffset; childParentData.offset = childOffset;
start += child.size.width + _kSeparatorWidth + _kSeparatorInset.horizontal; start += child.size.width + _kSeparatorWidth + _kSeparatorInset.horizontal;
@ -897,7 +897,7 @@ class _RenderSegmentedControl<T> extends RenderBox
final RenderBox selectedChild = children[highlightedIndex!]; final RenderBox selectedChild = children[highlightedIndex!];
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
selectedChild.parentData as _SegmentedControlContainerBoxParentData; selectedChild.parentData! as _SegmentedControlContainerBoxParentData;
final Rect unscaledThumbTargetRect = _kThumbInsets.inflateRect(childParentData.offset & selectedChild.size); final Rect unscaledThumbTargetRect = _kThumbInsets.inflateRect(childParentData.offset & selectedChild.size);
// Update related Tweens before animation update phase. // Update related Tweens before animation update phase.
@ -958,7 +958,7 @@ class _RenderSegmentedControl<T> extends RenderBox
void _paintSeparator(PaintingContext context, Offset offset, RenderBox child) { void _paintSeparator(PaintingContext context, Offset offset, RenderBox child) {
assert(child != null); assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final Paint paint = Paint(); final Paint paint = Paint();
@ -981,7 +981,7 @@ class _RenderSegmentedControl<T> extends RenderBox
void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) { void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) {
assert(child != null); assert(child != null);
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
context.paintChild(child, childParentData.offset + offset); context.paintChild(child, childParentData.offset + offset);
} }
@ -1023,7 +1023,7 @@ class _RenderSegmentedControl<T> extends RenderBox
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
if ((childParentData.offset & child.size).contains(position)) { if ((childParentData.offset & child.size).contains(position)) {
return result.addWithPaintOffset( return result.addWithPaintOffset(
offset: childParentData.offset, offset: childParentData.offset,

View File

@ -100,7 +100,7 @@ class _CupertinoTextFieldSelectionGestureDetectorBuilder extends TextSelectionGe
// this handler. If the clear button widget recognizes the up event, // this handler. If the clear button widget recognizes the up event,
// then do not handle it. // then do not handle it.
if (_state._clearGlobalKey.currentContext != null) { if (_state._clearGlobalKey.currentContext != null) {
final RenderBox renderBox = _state._clearGlobalKey.currentContext!.findRenderObject() as RenderBox; final RenderBox renderBox = _state._clearGlobalKey.currentContext!.findRenderObject()! as RenderBox;
final Offset localOffset = renderBox.globalToLocal(details.globalPosition); final Offset localOffset = renderBox.globalToLocal(details.globalPosition);
if (renderBox.hitTest(BoxHitTestResult(), position: localOffset)) { if (renderBox.hitTest(BoxHitTestResult(), position: localOffset)) {
return; return;
@ -905,7 +905,7 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
final Color? decorationColor = CupertinoDynamicColor.resolve(widget.decoration?.color, context); final Color? decorationColor = CupertinoDynamicColor.resolve(widget.decoration?.color, context);
final BoxBorder? border = widget.decoration?.border; final BoxBorder? border = widget.decoration?.border;
Border resolvedBorder = border as Border; Border? resolvedBorder = border as Border?;
if (border is Border) { if (border is Border) {
BorderSide resolveBorderSide(BorderSide side) { BorderSide resolveBorderSide(BorderSide side) {
return side == BorderSide.none return side == BorderSide.none

View File

@ -324,7 +324,7 @@ class _ToolbarRenderBox extends RenderShiftedBox {
.loosen(); .loosen();
child!.layout(heightConstraint.enforce(enforcedConstraint), parentUsesSize: true,); child!.layout(heightConstraint.enforce(enforcedConstraint), parentUsesSize: true,);
final _ToolbarParentData childParentData = child!.parentData as _ToolbarParentData; final _ToolbarParentData childParentData = child!.parentData! as _ToolbarParentData;
// The local x-coordinate of the center of the toolbar. // The local x-coordinate of the center of the toolbar.
final double lowerBound = child!.size.width/2 + _kToolbarScreenPadding; final double lowerBound = child!.size.width/2 + _kToolbarScreenPadding;
@ -337,7 +337,7 @@ class _ToolbarRenderBox extends RenderShiftedBox {
// The path is described in the toolbar's coordinate system. // The path is described in the toolbar's coordinate system.
Path _clipPath() { Path _clipPath() {
final _ToolbarParentData childParentData = child!.parentData as _ToolbarParentData; final _ToolbarParentData childParentData = child!.parentData! as _ToolbarParentData;
final Path rrect = Path() final Path rrect = Path()
..addRRect( ..addRRect(
RRect.fromRectAndRadius( RRect.fromRectAndRadius(
@ -370,7 +370,7 @@ class _ToolbarRenderBox extends RenderShiftedBox {
return; return;
} }
final _ToolbarParentData childParentData = child!.parentData as _ToolbarParentData; final _ToolbarParentData childParentData = child!.parentData! as _ToolbarParentData;
context.pushClipPath( context.pushClipPath(
needsCompositing, needsCompositing,
offset + childParentData.offset, offset + childParentData.offset,
@ -400,7 +400,7 @@ class _ToolbarRenderBox extends RenderShiftedBox {
..strokeWidth = 2.0 ..strokeWidth = 2.0
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke;
final _ToolbarParentData childParentData = child!.parentData as _ToolbarParentData; final _ToolbarParentData childParentData = child!.parentData! as _ToolbarParentData;
context.canvas.drawPath(_clipPath().shift(offset + childParentData.offset), _debugPaint!); context.canvas.drawPath(_clipPath().shift(offset + childParentData.offset), _debugPaint!);
return true; return true;
}()); }());
@ -789,11 +789,11 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
@override @override
void moveRenderObjectChild(RenderObject child, IndexedSlot<Element> oldSlot, IndexedSlot<Element> newSlot) { void moveRenderObjectChild(RenderObject child, IndexedSlot<Element> oldSlot, IndexedSlot<Element> newSlot) {
assert(child.parent == renderObject); assert(child.parent == renderObject);
renderObject.move(child as RenderBox, after: newSlot.value.renderObject as RenderBox); renderObject.move(child as RenderBox, after: newSlot.value.renderObject as RenderBox?);
} }
static bool _shouldPaint(Element child) { static bool _shouldPaint(Element child) {
return (child.renderObject!.parentData as ToolbarItemsParentData).shouldPaint; return (child.renderObject!.parentData! as ToolbarItemsParentData).shouldPaint;
} }
@override @override
@ -986,7 +986,7 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
i++; i++;
final RenderBox child = renderObjectChild as RenderBox; final RenderBox child = renderObjectChild as RenderBox;
final ToolbarItemsParentData childParentData = final ToolbarItemsParentData childParentData =
child.parentData as ToolbarItemsParentData; child.parentData! as ToolbarItemsParentData;
childParentData.shouldPaint = false; childParentData.shouldPaint = false;
// Skip slotted children and children on pages after the visible page. // Skip slotted children and children on pages after the visible page.
@ -1046,11 +1046,11 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
// Position page nav buttons. // Position page nav buttons.
if (currentPage > 0) { if (currentPage > 0) {
final ToolbarItemsParentData nextButtonParentData = final ToolbarItemsParentData nextButtonParentData =
_nextButton!.parentData as ToolbarItemsParentData; _nextButton!.parentData! as ToolbarItemsParentData;
final ToolbarItemsParentData nextButtonDisabledParentData = final ToolbarItemsParentData nextButtonDisabledParentData =
_nextButtonDisabled!.parentData as ToolbarItemsParentData; _nextButtonDisabled!.parentData! as ToolbarItemsParentData;
final ToolbarItemsParentData backButtonParentData = final ToolbarItemsParentData backButtonParentData =
_backButton!.parentData as ToolbarItemsParentData; _backButton!.parentData! as ToolbarItemsParentData;
// The forward button always shows if there is more than one page, even on // The forward button always shows if there is more than one page, even on
// the last page (it's just disabled). // the last page (it's just disabled).
if (page == currentPage) { if (page == currentPage) {
@ -1081,7 +1081,7 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
visitChildren((RenderObject renderObjectChild) { visitChildren((RenderObject renderObjectChild) {
final RenderBox child = renderObjectChild as RenderBox; final RenderBox child = renderObjectChild as RenderBox;
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
if (childParentData.shouldPaint) { if (childParentData.shouldPaint) {
final Offset childOffset = childParentData.offset + offset; final Offset childOffset = childParentData.offset + offset;
@ -1103,7 +1103,7 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
return false; return false;
} }
final ToolbarItemsParentData childParentData = final ToolbarItemsParentData childParentData =
child.parentData as ToolbarItemsParentData; child.parentData! as ToolbarItemsParentData;
return result.addWithPaintOffset( return result.addWithPaintOffset(
offset: childParentData.offset, offset: childParentData.offset,
position: position, position: position,
@ -1120,7 +1120,7 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
// The x, y parameters have the top left of the node's box as the origin. // The x, y parameters have the top left of the node's box as the origin.
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
// Don't hit test children that aren't shown. // Don't hit test children that aren't shown.
if (!childParentData.shouldPaint) { if (!childParentData.shouldPaint) {
@ -1199,7 +1199,7 @@ class _CupertinoTextSelectionToolbarItemsRenderBox extends RenderBox with Contai
void visitChildrenForSemantics(RenderObjectVisitor visitor) { void visitChildrenForSemantics(RenderObjectVisitor visitor) {
visitChildren((RenderObject renderObjectChild) { visitChildren((RenderObject renderObjectChild) {
final RenderBox child = renderObjectChild as RenderBox; final RenderBox child = renderObjectChild as RenderBox;
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
if (childParentData.shouldPaint) { if (childParentData.shouldPaint) {
visitor(renderObjectChild); visitor(renderObjectChild);
} }

View File

@ -591,7 +591,7 @@ class FlutterErrorDetails with Diagnosticable {
return exception; return exception;
} }
if (exception is AssertionError && exception.message is FlutterError) { if (exception is AssertionError && exception.message is FlutterError) {
return exception.message as FlutterError; return exception.message! as FlutterError;
} }
return null; return null;
} }

View File

@ -501,7 +501,7 @@ class _LicensePageState extends State<LicensePage> {
Widget _packageLicensePage(BuildContext _, Object? args, ScrollController? scrollController) { Widget _packageLicensePage(BuildContext _, Object? args, ScrollController? scrollController) {
assert(args is _DetailArguments); assert(args is _DetailArguments);
final _DetailArguments detailArguments = args as _DetailArguments; final _DetailArguments detailArguments = args! as _DetailArguments;
return _PackageLicensePage( return _PackageLicensePage(
packageName: detailArguments.packageName, packageName: detailArguments.packageName,
licenseEntries: detailArguments.licenseEntries, licenseEntries: detailArguments.licenseEntries,

View File

@ -187,7 +187,7 @@ class _BottomSheetState extends State<BottomSheet> {
final GlobalKey _childKey = GlobalKey(debugLabel: 'BottomSheet child'); final GlobalKey _childKey = GlobalKey(debugLabel: 'BottomSheet child');
double get _childHeight { double get _childHeight {
final RenderBox renderBox = _childKey.currentContext!.findRenderObject() as RenderBox; final RenderBox renderBox = _childKey.currentContext!.findRenderObject()! as RenderBox;
return renderBox.size.height; return renderBox.size.height;
} }

View File

@ -550,7 +550,7 @@ class _RenderInputPadding extends RenderShiftedBox {
final double height = math.max(child!.size.width, minSize.width); final double height = math.max(child!.size.width, minSize.width);
final double width = math.max(child!.size.height, minSize.height); final double width = math.max(child!.size.height, minSize.height);
size = constraints.constrain(Size(height, width)); size = constraints.constrain(Size(height, width));
final BoxParentData childParentData = child!.parentData as BoxParentData; final BoxParentData childParentData = child!.parentData! as BoxParentData;
childParentData.offset = Alignment.center.alongOffset(size - child!.size as Offset); childParentData.offset = Alignment.center.alongOffset(size - child!.size as Offset);
} else { } else {
size = Size.zero; size = Size.zero;

View File

@ -367,7 +367,7 @@ class _RenderButtonBarRow extends RenderFlex {
} }
while (child != null) { while (child != null) {
final FlexParentData childParentData = child.parentData as FlexParentData; final FlexParentData childParentData = child.parentData! as FlexParentData;
// Lay out the child with the button bar's original constraints, but // Lay out the child with the button bar's original constraints, but
// with minimum width set to zero. // with minimum width set to zero.

View File

@ -483,7 +483,7 @@ class _RenderInputPadding extends RenderShiftedBox {
final double height = math.max(child!.size.width, minSize.width); final double height = math.max(child!.size.width, minSize.width);
final double width = math.max(child!.size.height, minSize.height); final double width = math.max(child!.size.height, minSize.height);
size = constraints.constrain(Size(height, width)); size = constraints.constrain(Size(height, width));
final BoxParentData childParentData = child!.parentData as BoxParentData; final BoxParentData childParentData = child!.parentData! as BoxParentData;
childParentData.offset = Alignment.center.alongOffset(size - child!.size as Offset); childParentData.offset = Alignment.center.alongOffset(size - child!.size as Offset);
} else { } else {
size = Size.zero; size = Size.zero;

View File

@ -2128,13 +2128,13 @@ class _RenderChipElement extends RenderObjectElement {
void _updateRenderObject(RenderObject? child, _ChipSlot slot) { void _updateRenderObject(RenderObject? child, _ChipSlot slot) {
switch (slot) { switch (slot) {
case _ChipSlot.avatar: case _ChipSlot.avatar:
renderObject.avatar = child as RenderBox; renderObject.avatar = child as RenderBox?;
break; break;
case _ChipSlot.label: case _ChipSlot.label:
renderObject.label = child as RenderBox; renderObject.label = child as RenderBox?;
break; break;
case _ChipSlot.deleteIcon: case _ChipSlot.deleteIcon:
renderObject.deleteIcon = child as RenderBox; renderObject.deleteIcon = child as RenderBox?;
break; break;
} }
} }
@ -2385,7 +2385,7 @@ class _RenderChip extends RenderBox {
static Rect _boxRect(RenderBox? box) => box == null ? Rect.zero : _boxParentData(box).offset & box.size; static Rect _boxRect(RenderBox? box) => box == null ? Rect.zero : _boxParentData(box).offset & box.size;
static BoxParentData _boxParentData(RenderBox box) => box.parentData as BoxParentData; static BoxParentData _boxParentData(RenderBox box) => box.parentData! as BoxParentData;
@override @override
double computeMinIntrinsicWidth(double height) { double computeMinIntrinsicWidth(double height) {
@ -2907,7 +2907,7 @@ class _LocationAwareInkRippleFactory extends InteractiveInkFeatureFactory {
if (tapIsOnDeleteIcon) { if (tapIsOnDeleteIcon) {
final RenderBox currentBox = referenceBox; final RenderBox currentBox = referenceBox;
referenceBox = deleteIconKey.currentContext!.findRenderObject() as RenderBox; referenceBox = deleteIconKey.currentContext!.findRenderObject()! as RenderBox;
position = referenceBox.globalToLocal(currentBox.localToGlobal(position)); position = referenceBox.globalToLocal(currentBox.localToGlobal(position));
containedInkWell = false; containedInkWell = false;
} }

View File

@ -1030,7 +1030,7 @@ class TableRowInkWell extends InkResponse {
table = table.parent; table = table.parent;
} }
if (table is RenderTable) { if (table is RenderTable) {
final TableCellParentData cellParentData = cell.parentData as TableCellParentData; final TableCellParentData cellParentData = cell.parentData! as TableCellParentData;
assert(cellParentData.y != null); assert(cellParentData.y != null);
final Rect rect = table.getRowBox(cellParentData.y!); final Rect rect = table.getRowBox(cellParentData.y!);
// The rect is in the table's coordinate space. We need to change it to the // The rect is in the table's coordinate space. We need to change it to the

View File

@ -1179,7 +1179,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
TextStyle? get _textStyle => widget.style ?? Theme.of(context)!.textTheme.subtitle1; TextStyle? get _textStyle => widget.style ?? Theme.of(context)!.textTheme.subtitle1;
void _handleTap() { void _handleTap() {
final RenderBox itemBox = context.findRenderObject() as RenderBox; final RenderBox itemBox = context.findRenderObject()! as RenderBox;
final Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size; final Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
final TextDirection? textDirection = Directionality.of(context); final TextDirection? textDirection = Directionality.of(context);
final EdgeInsetsGeometry menuMargin = ButtonTheme.of(context).alignedDropdown final EdgeInsetsGeometry menuMargin = ButtonTheme.of(context).alignedDropdown

View File

@ -255,7 +255,7 @@ class _InkState extends State<Ink> {
decoration: widget.decoration, decoration: widget.decoration,
configuration: createLocalImageConfiguration(context), configuration: createLocalImageConfiguration(context),
controller: Material.of(context)!, controller: Material.of(context)!,
referenceBox: context.findRenderObject() as RenderBox, referenceBox: context.findRenderObject()! as RenderBox,
onRemoved: _handleRemoved, onRemoved: _handleRemoved,
); );
} else { } else {

View File

@ -62,7 +62,7 @@ class _InputBorderTween extends Tween<InputBorder> {
_InputBorderTween({InputBorder? begin, InputBorder? end}) : super(begin: begin, end: end); _InputBorderTween({InputBorder? begin, InputBorder? end}) : super(begin: begin, end: end);
@override @override
InputBorder lerp(double t) => ShapeBorder.lerp(begin, end, t) as InputBorder; InputBorder lerp(double t) => ShapeBorder.lerp(begin, end, t)! as InputBorder;
} }
// Passes the _InputBorderGap parameters along to an InputBorder's paint method. // Passes the _InputBorderGap parameters along to an InputBorder's paint method.
@ -919,7 +919,7 @@ class _RenderDecoration extends RenderBox {
static Size _boxSize(RenderBox? box) => box == null ? Size.zero : box.size; static Size _boxSize(RenderBox? box) => box == null ? Size.zero : box.size;
static BoxParentData _boxParentData(RenderBox box) => box.parentData as BoxParentData; static BoxParentData _boxParentData(RenderBox box) => box.parentData! as BoxParentData;
EdgeInsets get contentPadding => decoration.contentPadding as EdgeInsets; EdgeInsets get contentPadding => decoration.contentPadding as EdgeInsets;

View File

@ -1688,7 +1688,7 @@ class _RenderListTile extends RenderBox {
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
void doPaint(RenderBox? child) { void doPaint(RenderBox? child) {
if (child != null) { if (child != null) {
final BoxParentData parentData = child.parentData as BoxParentData; final BoxParentData parentData = child.parentData! as BoxParentData;
context.paintChild(child, parentData.offset + offset); context.paintChild(child, parentData.offset + offset);
} }
} }
@ -1705,7 +1705,7 @@ class _RenderListTile extends RenderBox {
bool hitTestChildren(BoxHitTestResult result, { required Offset position }) { bool hitTestChildren(BoxHitTestResult result, { required Offset position }) {
assert(position != null); assert(position != null);
for (final RenderBox child in _children) { for (final RenderBox child in _children) {
final BoxParentData parentData = child.parentData as BoxParentData; final BoxParentData parentData = child.parentData! as BoxParentData;
final bool isHit = result.addWithPaintOffset( final bool isHit = result.addWithPaintOffset(
offset: parentData.offset, offset: parentData.offset,
position: position, position: position,

View File

@ -637,8 +637,7 @@ abstract class InkFeature {
final List<RenderObject> descendants = <RenderObject>[referenceBox]; final List<RenderObject> descendants = <RenderObject>[referenceBox];
RenderObject node = referenceBox; RenderObject node = referenceBox;
while (node != _controller) { while (node != _controller) {
node = node.parent as RenderObject; node = node.parent! as RenderObject;
assert(node != null);
descendants.add(node); descendants.add(node);
} }
// determine the transform that gets our coordinate system to be like theirs // determine the transform that gets our coordinate system to be like theirs
@ -763,17 +762,17 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior>
_elevation, _elevation,
widget.elevation, widget.elevation,
(dynamic value) => Tween<double>(begin: value as double), (dynamic value) => Tween<double>(begin: value as double),
) as Tween<double>; ) as Tween<double>?;
_shadowColor = visitor( _shadowColor = visitor(
_shadowColor, _shadowColor,
widget.shadowColor, widget.shadowColor,
(dynamic value) => ColorTween(begin: value as Color), (dynamic value) => ColorTween(begin: value as Color),
) as ColorTween; ) as ColorTween?;
_border = visitor( _border = visitor(
_border, _border,
widget.shape, widget.shape,
(dynamic value) => ShapeBorderTween(begin: value as ShapeBorder), (dynamic value) => ShapeBorderTween(begin: value as ShapeBorder),
) as ShapeBorderTween; ) as ShapeBorderTween?;
} }
@override @override

View File

@ -2570,7 +2570,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
clipBehavior: clipBehavior, clipBehavior: clipBehavior,
); );
}); });
return _currentBottomSheet as PersistentBottomSheetController<T>; return _currentBottomSheet! as PersistentBottomSheetController<T>;
} }
// Floating Action Button API // Floating Action Button API

View File

@ -240,7 +240,7 @@ class _TabLabelBarRenderer extends RenderFlex {
RenderBox? child = firstChild; RenderBox? child = firstChild;
final List<double> xOffsets = <double>[]; final List<double> xOffsets = <double>[];
while (child != null) { while (child != null) {
final FlexParentData childParentData = child.parentData as FlexParentData; final FlexParentData childParentData = child.parentData! as FlexParentData;
xOffsets.add(childParentData.offset.dx); xOffsets.add(childParentData.offset.dx);
assert(child.parentData == childParentData); assert(child.parentData == childParentData);
child = childParentData.nextSibling; child = childParentData.nextSibling;

View File

@ -550,7 +550,7 @@ class _TextSelectionToolbarItemsRenderBox extends RenderBox with ContainerRender
}); });
// Place the navigation button if needed. // Place the navigation button if needed.
final ToolbarItemsParentData navButtonParentData = navButton.parentData as ToolbarItemsParentData; final ToolbarItemsParentData navButtonParentData = navButton.parentData! as ToolbarItemsParentData;
if (_shouldPaintChild(firstChild!, 0)) { if (_shouldPaintChild(firstChild!, 0)) {
navButtonParentData.shouldPaint = true; navButtonParentData.shouldPaint = true;
if (overflowOpen) { if (overflowOpen) {
@ -588,7 +588,7 @@ class _TextSelectionToolbarItemsRenderBox extends RenderBox with ContainerRender
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
visitChildren((RenderObject renderObjectChild) { visitChildren((RenderObject renderObjectChild) {
final RenderBox child = renderObjectChild as RenderBox; final RenderBox child = renderObjectChild as RenderBox;
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
if (!childParentData.shouldPaint) { if (!childParentData.shouldPaint) {
return; return;
} }
@ -609,7 +609,7 @@ class _TextSelectionToolbarItemsRenderBox extends RenderBox with ContainerRender
// The x, y parameters have the top left of the node's box as the origin. // The x, y parameters have the top left of the node's box as the origin.
RenderBox? child = lastChild; RenderBox? child = lastChild;
while (child != null) { while (child != null) {
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
// Don't hit test children aren't shown. // Don't hit test children aren't shown.
if (!childParentData.shouldPaint) { if (!childParentData.shouldPaint) {
@ -637,7 +637,7 @@ class _TextSelectionToolbarItemsRenderBox extends RenderBox with ContainerRender
void visitChildrenForSemantics(RenderObjectVisitor visitor) { void visitChildrenForSemantics(RenderObjectVisitor visitor) {
visitChildren((RenderObject renderObjectChild) { visitChildren((RenderObject renderObjectChild) {
final RenderBox child = renderObjectChild as RenderBox; final RenderBox child = renderObjectChild as RenderBox;
final ToolbarItemsParentData childParentData = child.parentData as ToolbarItemsParentData; final ToolbarItemsParentData childParentData = child.parentData! as ToolbarItemsParentData;
if (childParentData.shouldPaint) { if (childParentData.shouldPaint) {
visitor(renderObjectChild); visitor(renderObjectChild);
} }

View File

@ -254,8 +254,7 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState<AnimatedTheme> {
@override @override
void forEachTween(TweenVisitor<dynamic> visitor) { void forEachTween(TweenVisitor<dynamic> visitor) {
// TODO(ianh): Use constructor tear-offs when it becomes possible, https://github.com/dart-lang/sdk/issues/10659 // TODO(ianh): Use constructor tear-offs when it becomes possible, https://github.com/dart-lang/sdk/issues/10659
_data = visitor(_data, widget.data, (dynamic value) => ThemeDataTween(begin: value as ThemeData)) as ThemeDataTween; _data = visitor(_data, widget.data, (dynamic value) => ThemeDataTween(begin: value as ThemeData))! as ThemeDataTween;
assert(_data != null);
} }
@override @override

View File

@ -1037,7 +1037,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
void _handlePanStart(DragStartDetails details) { void _handlePanStart(DragStartDetails details) {
assert(!_dragging); assert(!_dragging);
_dragging = true; _dragging = true;
final RenderBox box = context.findRenderObject() as RenderBox; final RenderBox box = context.findRenderObject()! as RenderBox;
_position = box.globalToLocal(details.globalPosition); _position = box.globalToLocal(details.globalPosition);
_center = box.size.center(Offset.zero); _center = box.size.center(Offset.zero);
_updateThetaForPan(); _updateThetaForPan();
@ -1064,7 +1064,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
} }
void _handleTapUp(TapUpDetails details) { void _handleTapUp(TapUpDetails details) {
final RenderBox box = context.findRenderObject() as RenderBox; final RenderBox box = context.findRenderObject()! as RenderBox;
_position = box.globalToLocal(details.globalPosition); _position = box.globalToLocal(details.globalPosition);
_center = box.size.center(Offset.zero); _center = box.size.center(Offset.zero);
_updateThetaForPan(roundMinutes: true); _updateThetaForPan(roundMinutes: true);

View File

@ -272,7 +272,7 @@ class TimePickerThemeData with Diagnosticable {
helpTextStyle: TextStyle.lerp(a?.helpTextStyle, b?.helpTextStyle, t), helpTextStyle: TextStyle.lerp(a?.helpTextStyle, b?.helpTextStyle, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t), shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
hourMinuteShape: ShapeBorder.lerp(a?.hourMinuteShape, b?.hourMinuteShape, t), hourMinuteShape: ShapeBorder.lerp(a?.hourMinuteShape, b?.hourMinuteShape, t),
dayPeriodShape: ShapeBorder.lerp(a?.dayPeriodShape, b?.dayPeriodShape, t) as OutlinedBorder, dayPeriodShape: ShapeBorder.lerp(a?.dayPeriodShape, b?.dayPeriodShape, t) as OutlinedBorder?,
dayPeriodBorderSide: lerpedBorderSide, dayPeriodBorderSide: lerpedBorderSide,
inputDecorationTheme: t < 0.5 ? a?.inputDecorationTheme : b?.inputDecorationTheme, inputDecorationTheme: t < 0.5 ? a?.inputDecorationTheme : b?.inputDecorationTheme,
); );

View File

@ -4978,7 +4978,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
return _history.cast<_RouteEntry?>().firstWhere( return _history.cast<_RouteEntry?>().firstWhere(
(_RouteEntry? entry) => entry!.restorationId == id, (_RouteEntry? entry) => entry!.restorationId == id,
orElse: () => null, orElse: () => null,
)?.route as Route<T>; )?.route as Route<T>?;
} }
int get _userGesturesInProgress => _userGesturesInProgressCount; int get _userGesturesInProgress => _userGesturesInProgressCount;
@ -5208,8 +5208,7 @@ class _AnonymousRestorationInformation extends _RestorationInformation {
factory _AnonymousRestorationInformation.fromSerializableData(List<Object> data) { factory _AnonymousRestorationInformation.fromSerializableData(List<Object> data) {
assert(data.length > 1); assert(data.length > 1);
final RestorableRouteBuilder routeBuilder = ui.PluginUtilities.getCallbackFromHandle(ui.CallbackHandle.fromRawHandle(data[1] as int)) as RestorableRouteBuilder; final RestorableRouteBuilder routeBuilder = ui.PluginUtilities.getCallbackFromHandle(ui.CallbackHandle.fromRawHandle(data[1] as int))! as RestorableRouteBuilder;
assert(routeBuilder != null);
return _AnonymousRestorationInformation( return _AnonymousRestorationInformation(
restorationScopeId: data[0] as int, restorationScopeId: data[0] as int,
routeBuilder: routeBuilder, routeBuilder: routeBuilder,

View File

@ -505,7 +505,7 @@ void main() {
setUp(() { color = null; }); setUp(() { color = null; });
testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async { testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async {
final CupertinoDynamicColor Function() typedColor = () => color as CupertinoDynamicColor; final CupertinoDynamicColor Function() typedColor = () => color! as CupertinoDynamicColor;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(

View File

@ -40,7 +40,7 @@ void main() {
); );
expect(finder, findsOneWidget); expect(finder, findsOneWidget);
final Container container = tester.widget(finder); final Container container = tester.widget(finder);
return container.decoration as BoxDecoration; return container.decoration! as BoxDecoration;
} }
TextStyle _getTextStyle(WidgetTester tester) { TextStyle _getTextStyle(WidgetTester tester) {

View File

@ -390,8 +390,8 @@ void main() {
List<Element> titles = tester.elementList(find.text('Title')) List<Element> titles = tester.elementList(find.text('Title'))
.toList() .toList()
..sort((Element a, Element b) { ..sort((Element a, Element b) {
final RenderParagraph aParagraph = a.renderObject as RenderParagraph; final RenderParagraph aParagraph = a.renderObject! as RenderParagraph;
final RenderParagraph bParagraph = b.renderObject as RenderParagraph; final RenderParagraph bParagraph = b.renderObject! as RenderParagraph;
return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!); return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!);
}); });
@ -415,8 +415,8 @@ void main() {
titles = tester.elementList(find.text('Title')) titles = tester.elementList(find.text('Title'))
.toList() .toList()
..sort((Element a, Element b) { ..sort((Element a, Element b) {
final RenderParagraph aParagraph = a.renderObject as RenderParagraph; final RenderParagraph aParagraph = a.renderObject! as RenderParagraph;
final RenderParagraph bParagraph = b.renderObject as RenderParagraph; final RenderParagraph bParagraph = b.renderObject! as RenderParagraph;
return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!); return aParagraph.text.style!.fontSize!.compareTo(bParagraph.text.style!.fontSize!);
}); });

View File

@ -83,8 +83,8 @@ void main() {
final List<Element> titles = tester.elementList(find.text('An iPod')) final List<Element> titles = tester.elementList(find.text('An iPod'))
.toList() .toList()
..sort((Element a, Element b) { ..sort((Element a, Element b) {
final RenderParagraph aParagraph = a.renderObject as RenderParagraph; final RenderParagraph aParagraph = a.renderObject! as RenderParagraph;
final RenderParagraph bParagraph = b.renderObject as RenderParagraph; final RenderParagraph bParagraph = b.renderObject! as RenderParagraph;
return aParagraph.text.style!.fontSize!.compareTo( return aParagraph.text.style!.fontSize!.compareTo(
bParagraph.text.style!.fontSize! bParagraph.text.style!.fontSize!
); );

View File

@ -301,7 +301,7 @@ void main() {
final BoxDecoration decoration = tester.widget<Container>(find.descendant( final BoxDecoration decoration = tester.widget<Container>(find.descendant(
of: find.byType(UnconstrainedBox), of: find.byType(UnconstrainedBox),
matching: find.byType(Container), matching: find.byType(Container),
)).decoration as BoxDecoration; )).decoration! as BoxDecoration;
expect(getRenderSegmentedControl(tester).thumbColor.value, CupertinoColors.systemGreen.color.value); expect(getRenderSegmentedControl(tester).thumbColor.value, CupertinoColors.systemGreen.color.value);
expect(decoration.color!.value, CupertinoColors.systemRed.color.value); expect(decoration.color!.value, CupertinoColors.systemRed.color.value);
@ -312,7 +312,7 @@ void main() {
final BoxDecoration decorationDark = tester.widget<Container>(find.descendant( final BoxDecoration decorationDark = tester.widget<Container>(find.descendant(
of: find.byType(UnconstrainedBox), of: find.byType(UnconstrainedBox),
matching: find.byType(Container), matching: find.byType(Container),
)).decoration as BoxDecoration; )).decoration! as BoxDecoration;
expect(getRenderSegmentedControl(tester).thumbColor.value, CupertinoColors.systemGreen.darkColor.value); expect(getRenderSegmentedControl(tester).thumbColor.value, CupertinoColors.systemGreen.darkColor.value);

View File

@ -76,7 +76,7 @@ void main() {
test('subtreeDepth 1', () { test('subtreeDepth 1', () {
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1)); final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1));
expect(result.containsKey('properties'), isFalse); expect(result.containsKey('properties'), isFalse);
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children[0].containsKey('children'), isFalse); expect(children[0].containsKey('children'), isFalse);
expect(children[1].containsKey('children'), isFalse); expect(children[1].containsKey('children'), isFalse);
expect(children[2].containsKey('children'), isFalse); expect(children[2].containsKey('children'), isFalse);
@ -85,7 +85,7 @@ void main() {
test('subtreeDepth 5', () { test('subtreeDepth 5', () {
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5)); final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5));
expect(result.containsKey('properties'), isFalse); expect(result.containsKey('properties'), isFalse);
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children[0]['children'], hasLength(0)); expect(children[0]['children'], hasLength(0));
expect(children[1]['children'], hasLength(3)); expect(children[1]['children'], hasLength(3));
expect(children[2]['children'], hasLength(0)); expect(children[2]['children'], hasLength(0));
@ -103,7 +103,7 @@ void main() {
subtreeDepth: 1, subtreeDepth: 1,
)); ));
expect(result['properties'], hasLength(7)); expect(result['properties'], hasLength(7));
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(3)); expect(children, hasLength(3));
expect(children[0]['properties'], hasLength(0)); expect(children[0]['properties'], hasLength(0));
expect(children[1]['properties'], hasLength(2)); expect(children[1]['properties'], hasLength(2));
@ -119,11 +119,11 @@ void main() {
}, },
)); ));
expect(result['foo'], isTrue); expect(result['foo'], isTrue);
final List<Map<String, Object>> properties = result['properties'] as List<Map<String, Object>>; final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
expect(properties, hasLength(7)); expect(properties, hasLength(7));
expect(properties.every((Map<String, Object> property) => property['foo'] == true), isTrue); expect(properties.every((Map<String, Object> property) => property['foo'] == true), isTrue);
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(3)); expect(children, hasLength(3));
expect(children.every((Map<String, Object> child) => child['foo'] == true), isTrue); expect(children.every((Map<String, Object> child) => child['foo'] == true), isTrue);
}); });
@ -135,7 +135,7 @@ void main() {
return nodes.whereType<StringProperty>().toList(); return nodes.whereType<StringProperty>().toList();
}, },
)); ));
final List<Map<String, Object>> properties = result['properties'] as List<Map<String, Object>>; final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
expect(properties, hasLength(3)); expect(properties, hasLength(3));
expect(properties.every((Map<String, Object> property) => property['type'] == 'StringProperty'), isTrue); expect(properties.every((Map<String, Object> property) => property['type'] == 'StringProperty'), isTrue);
}); });
@ -154,7 +154,7 @@ void main() {
]; ];
}, },
)); ));
final List<Map<String, Object>> properties = result['properties'] as List<Map<String, Object>>; final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
expect(properties, hasLength(1)); expect(properties, hasLength(1));
expect(properties.single['name'], 'foo'); expect(properties.single['name'], 'foo');
}); });
@ -166,7 +166,7 @@ void main() {
return nodes.where((DiagnosticsNode node) => node.getProperties().isEmpty).toList(); return nodes.where((DiagnosticsNode node) => node.getProperties().isEmpty).toList();
}, },
)); ));
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(1)); expect(children, hasLength(1));
}); });
@ -177,7 +177,7 @@ void main() {
return nodes.expand((DiagnosticsNode node) => node.getChildren()).toList(); return nodes.expand((DiagnosticsNode node) => node.getChildren()).toList();
}, },
)); ));
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(3)); expect(children, hasLength(3));
expect(children.first['name'], 'child node B1'); expect(children.first['name'], 'child node B1');
}); });
@ -190,11 +190,11 @@ void main() {
return nodes.take(2).toList(); return nodes.take(2).toList();
}, },
)); ));
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(3)); expect(children, hasLength(3));
expect(children.last['truncated'], isTrue); expect(children.last['truncated'], isTrue);
final List<Map<String, Object>> properties = result['properties'] as List<Map<String, Object>>; final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
expect(properties, hasLength(3)); expect(properties, hasLength(3));
expect(properties.last['truncated'], isTrue); expect(properties.last['truncated'], isTrue);
}); });
@ -207,11 +207,11 @@ void main() {
return delegate.copyWith(includeProperties: false); return delegate.copyWith(includeProperties: false);
}, },
)); ));
final List<Map<String, Object>> properties = result['properties'] as List<Map<String, Object>>; final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
expect(properties, hasLength(7)); expect(properties, hasLength(7));
expect(properties.every((Map<String, Object> property) => !property.containsKey('properties')), isTrue); expect(properties.every((Map<String, Object> property) => !property.containsKey('properties')), isTrue);
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>; final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
expect(children, hasLength(3)); expect(children, hasLength(3));
expect(children.every((Map<String, Object> child) => !child.containsKey('properties')), isTrue); expect(children.every((Map<String, Object> child) => !child.containsKey('properties')), isTrue);
}); });

View File

@ -137,7 +137,7 @@ void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> proper
void validateIterablePropertyJsonSerialization(IterableProperty<Object> property) { void validateIterablePropertyJsonSerialization(IterableProperty<Object> property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object> json = simulateJsonSerialization(property);
if (property.value != null) { if (property.value != null) {
final List<Object> valuesJson = json['values'] as List<Object>; final List<Object> valuesJson = json['values']! as List<Object>;
final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList(); final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList();
expect(listEquals(valuesJson, expectedValues), isTrue); expect(listEquals(valuesJson, expectedValues), isTrue);
} else { } else {

View File

@ -25,7 +25,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
@ -47,7 +47,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
@ -67,7 +67,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.image!.fit, equals(BoxFit.cover)); expect(decoration.image!.fit, equals(BoxFit.cover));
}); });
@ -87,7 +87,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(40.0, 40.0))); expect(box.size, equals(const Size(40.0, 40.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(fallback.primaryColorDark)); expect(decoration.color, equals(fallback.primaryColorDark));
@ -112,7 +112,7 @@ void main() {
); );
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(theme.primaryColorLight)); expect(decoration.color, equals(theme.primaryColorLight));
@ -137,7 +137,7 @@ void main() {
); );
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(theme.primaryColorDark)); expect(decoration.color, equals(theme.primaryColorDark));
@ -204,7 +204,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
@ -226,7 +226,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));
@ -249,7 +249,7 @@ void main() {
final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar));
expect(box.size, equals(const Size(100.0, 100.0))); expect(box.size, equals(const Size(100.0, 100.0)));
final RenderDecoratedBox child = box.child as RenderDecoratedBox; final RenderDecoratedBox child = box.child! as RenderDecoratedBox;
final BoxDecoration decoration = child.decoration as BoxDecoration; final BoxDecoration decoration = child.decoration as BoxDecoration;
expect(decoration.color, equals(backgroundColor)); expect(decoration.color, equals(backgroundColor));

View File

@ -956,7 +956,7 @@ void main() {
Table table = tester.widget(find.byType(Table)); Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last; TableRow tableRow = table.children.last;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration; BoxDecoration boxDecoration = tableRow.decoration! as BoxDecoration;
expect(boxDecoration.border!.top.width, 1.0); expect(boxDecoration.border!.top.width, 1.0);
const double thickness = 4.2; const double thickness = 4.2;
@ -973,7 +973,7 @@ void main() {
); );
table = tester.widget(find.byType(Table)); table = tester.widget(find.byType(Table));
tableRow = table.children.last; tableRow = table.children.last;
boxDecoration = tableRow.decoration as BoxDecoration; boxDecoration = tableRow.decoration! as BoxDecoration;
expect(boxDecoration.border!.top.width, thickness); expect(boxDecoration.border!.top.width, thickness);
}); });
@ -1007,7 +1007,7 @@ void main() {
Table table = tester.widget(find.byType(Table)); Table table = tester.widget(find.byType(Table));
TableRow tableRow = table.children.last; TableRow tableRow = table.children.last;
BoxDecoration boxDecoration = tableRow.decoration as BoxDecoration; BoxDecoration boxDecoration = tableRow.decoration! as BoxDecoration;
expect(boxDecoration.border!.bottom.width, 1.0); expect(boxDecoration.border!.bottom.width, 1.0);
await tester.pumpWidget( await tester.pumpWidget(
@ -1022,7 +1022,7 @@ void main() {
); );
table = tester.widget(find.byType(Table)); table = tester.widget(find.byType(Table));
tableRow = table.children.last; tableRow = table.children.last;
boxDecoration = tableRow.decoration as BoxDecoration; boxDecoration = tableRow.decoration! as BoxDecoration;
expect(boxDecoration.border!.bottom.width, 0.0); expect(boxDecoration.border!.bottom.width, 0.0);
}); });
@ -1175,7 +1175,7 @@ void main() {
BoxDecoration lastTableRowBoxDecoration() { BoxDecoration lastTableRowBoxDecoration() {
final Table table = tester.widget(find.byType(Table)); final Table table = tester.widget(find.byType(Table));
final TableRow tableRow = table.children.last; final TableRow tableRow = table.children.last;
return tableRow.decoration as BoxDecoration; return tableRow.decoration! as BoxDecoration;
} }
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -1229,7 +1229,7 @@ void main() {
BoxDecoration lastTableRowBoxDecoration() { BoxDecoration lastTableRowBoxDecoration() {
final Table table = tester.widget(find.byType(Table)); final Table table = tester.widget(find.byType(Table));
final TableRow tableRow = table.children.last; final TableRow tableRow = table.children.last;
return tableRow.decoration as BoxDecoration; return tableRow.decoration! as BoxDecoration;
} }
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -1276,7 +1276,7 @@ void main() {
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Content1'))); final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Content1')));
await tester.pump(const Duration(milliseconds: 200)); // splash is well underway await tester.pump(const Duration(milliseconds: 200)); // splash is well underway
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
expect(box, paints..circle(x: 68.0, y: 24.0, color: pressedColor)); expect(box, paints..circle(x: 68.0, y: 24.0, color: pressedColor));
await gesture.up(); await gesture.up();
}); });

View File

@ -246,5 +246,5 @@ void main() {
BoxDecoration _tableRowBoxDecoration({required WidgetTester tester, required int index}) { BoxDecoration _tableRowBoxDecoration({required WidgetTester tester, required int index}) {
final Table table = tester.widget(find.byType(Table)); final Table table = tester.widget(find.byType(Table));
final TableRow tableRow = table.children[index]; final TableRow tableRow = table.children[index];
return tableRow.decoration as BoxDecoration; return tableRow.decoration! as BoxDecoration;
} }

View File

@ -635,7 +635,7 @@ void main() {
BorderSide getBorderSide() { BorderSide getBorderSide() {
final OutlinedBorder border = tester.widget<Material>( final OutlinedBorder border = tester.widget<Material>(
find.descendant(of: outlinedButton, matching: find.byType(Material)) find.descendant(of: outlinedButton, matching: find.byType(Material))
).shape as OutlinedBorder; ).shape! as OutlinedBorder;
return border.side; return border.side;
} }
@ -1180,11 +1180,11 @@ PhysicalModelLayer _findPhysicalLayer(Element element) {
expect(element, isNotNull); expect(element, isNotNull);
RenderObject? object = element.renderObject; RenderObject? object = element.renderObject;
while (object != null && object is! RenderRepaintBoundary && object is! RenderView) { while (object != null && object is! RenderRepaintBoundary && object is! RenderView) {
object = object.parent as RenderObject; object = object.parent as RenderObject?;
} }
expect(object!.debugLayer, isNotNull); expect(object!.debugLayer, isNotNull);
expect(object.debugLayer!.firstChild, isA<PhysicalModelLayer>()); expect(object.debugLayer!.firstChild, isA<PhysicalModelLayer>());
final PhysicalModelLayer layer = object.debugLayer!.firstChild as PhysicalModelLayer; final PhysicalModelLayer layer = object.debugLayer!.firstChild! as PhysicalModelLayer;
final Layer child = layer.firstChild!; final Layer child = layer.firstChild!;
return child is PhysicalModelLayer ? child : layer; return child is PhysicalModelLayer ? child : layer;
} }

View File

@ -32,7 +32,7 @@ void main() {
await tester.tap(find.text('BUTTON')); await tester.tap(find.text('BUTTON'));
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
final RenderBox splash = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox splash = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
expect(splash, paints..circle(color: splashColor)); expect(splash, paints..circle(color: splashColor));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -72,7 +72,7 @@ void main() {
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
if (!kIsWeb) { if (!kIsWeb) {
final RenderBox splash = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox splash = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
expect(splash, paints..circle(color: splashColor)); expect(splash, paints..circle(color: splashColor));
} }
@ -90,7 +90,7 @@ void main() {
await tester.sendKeyEvent(LogicalKeyboardKey.space); await tester.sendKeyEvent(LogicalKeyboardKey.space);
await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10));
final RenderBox splash = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox splash = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
expect(splash, paints..circle(color: splashColor)); expect(splash, paints..circle(color: splashColor));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@ -195,7 +195,7 @@ void main() {
await tester.pump(); // start gesture await tester.pump(); // start gesture
await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
// centered in material button. // centered in material button.
expect(box, paints..circle(x: 44.0, y: 18.0, color: splashColor)); expect(box, paints..circle(x: 44.0, y: 18.0, color: splashColor));
await gesture.up(); await gesture.up();
@ -226,7 +226,7 @@ void main() {
final TestGesture gesture = await tester.startGesture(top); final TestGesture gesture = await tester.startGesture(top);
await tester.pump(); // start gesture await tester.pump(); // start gesture
await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
// paints above above material // paints above above material
expect(box, paints..circle(x: 44.0, y: 0.0, color: splashColor)); expect(box, paints..circle(x: 44.0, y: 0.0, color: splashColor));
await gesture.up(); await gesture.up();
@ -325,7 +325,7 @@ void main() {
), ),
), ),
); );
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
expect(box, isNot(paints..rect(color: focusColor))); expect(box, isNot(paints..rect(color: focusColor)));
focusNode.requestFocus(); focusNode.requestFocus();
@ -424,7 +424,7 @@ void main() {
), ),
), ),
); );
final RenderBox box = Material.of(tester.element(find.byType(InkWell))) as RenderBox; final RenderBox box = Material.of(tester.element(find.byType(InkWell)))! as RenderBox;
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer); addTearDown(gesture.removePointer);

View File

@ -429,7 +429,7 @@ void main() {
test('ColorDiagnosticsProperty includes valueProperties in JSON', () { test('ColorDiagnosticsProperty includes valueProperties in JSON', () {
ColorProperty property = ColorProperty('foo', const Color.fromARGB(10, 20, 30, 40)); ColorProperty property = ColorProperty('foo', const Color.fromARGB(10, 20, 30, 40));
final Map<String, Object> valueProperties = property.toJsonMap(const DiagnosticsSerializationDelegate())['valueProperties'] as Map<String, Object>; final Map<String, Object> valueProperties = property.toJsonMap(const DiagnosticsSerializationDelegate())['valueProperties']! as Map<String, Object>;
expect(valueProperties['alpha'], 10); expect(valueProperties['alpha'], 10);
expect(valueProperties['red'], 20); expect(valueProperties['red'], 20);
expect(valueProperties['green'], 30); expect(valueProperties['green'], 30);

View File

@ -134,13 +134,13 @@ void main() {
const BoxDecoration a = BoxDecoration(color: Color(0xFFFFFFFF)); const BoxDecoration a = BoxDecoration(color: Color(0xFFFFFFFF));
const BoxDecoration b = BoxDecoration(color: Color(0x00000000)); const BoxDecoration b = BoxDecoration(color: Color(0x00000000));
BoxDecoration c = Decoration.lerp(a, b, 0.0) as BoxDecoration; BoxDecoration c = Decoration.lerp(a, b, 0.0)! as BoxDecoration;
expect(c.color, equals(a.color)); expect(c.color, equals(a.color));
c = Decoration.lerp(a, b, 0.25) as BoxDecoration; c = Decoration.lerp(a, b, 0.25)! as BoxDecoration;
expect(c.color, equals(Color.lerp(const Color(0xFFFFFFFF), const Color(0x00000000), 0.25))); expect(c.color, equals(Color.lerp(const Color(0xFFFFFFFF), const Color(0x00000000), 0.25)));
c = Decoration.lerp(a, b, 1.0) as BoxDecoration; c = Decoration.lerp(a, b, 1.0)! as BoxDecoration;
expect(c.color, equals(b.color)); expect(c.color, equals(b.color));
}); });

View File

@ -161,10 +161,10 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () {
return completer2; return completer2;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(resultingCompleter1, completer1); expect(resultingCompleter1, completer1);
expect(resultingCompleter2, completer1); expect(resultingCompleter2, completer1);
@ -178,7 +178,7 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(imageCache!.statusForKey(testImage).pending, true); expect(imageCache!.statusForKey(testImage).pending, true);
expect(imageCache!.statusForKey(testImage).live, true); expect(imageCache!.statusForKey(testImage).live, true);
@ -191,7 +191,7 @@ void main() {
final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () {
return completer2; return completer2;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(resultingCompleter1, completer1); expect(resultingCompleter1, completer1);
expect(resultingCompleter2, completer2); expect(resultingCompleter2, completer2);
@ -205,13 +205,13 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
imageCache!.evict(testImage); imageCache!.evict(testImage);
final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage, () {
return completer2; return completer2;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(resultingCompleter1, completer1); expect(resultingCompleter1, completer1);
expect(resultingCompleter2, completer2); expect(resultingCompleter2, completer2);
@ -242,7 +242,7 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(resultingCompleter1, completer1); expect(resultingCompleter1, completer1);
expect(imageCache!.containsKey(testImage), true); expect(imageCache!.containsKey(testImage), true);
@ -255,7 +255,7 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
// Mark as complete // Mark as complete
completer1.testSetImage(testImage); completer1.testSetImage(testImage);
@ -276,7 +276,7 @@ void main() {
final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () { final TestImageStreamCompleter resultingCompleter1 = imageCache!.putIfAbsent(testImage, () {
return completer1; return completer1;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(imageCache!.statusForKey(testImage).pending, false); expect(imageCache!.statusForKey(testImage).pending, false);
expect(imageCache!.statusForKey(testImage).keepAlive, true); expect(imageCache!.statusForKey(testImage).keepAlive, true);
@ -284,7 +284,7 @@ void main() {
expect(imageCache!.statusForKey(testImage2).untracked, true); expect(imageCache!.statusForKey(testImage2).untracked, true);
final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage2, () { final TestImageStreamCompleter resultingCompleter2 = imageCache!.putIfAbsent(testImage2, () {
return completer2; return completer2;
}) as TestImageStreamCompleter; })! as TestImageStreamCompleter;
expect(imageCache!.statusForKey(testImage).pending, false); expect(imageCache!.statusForKey(testImage).pending, false);

View File

@ -43,7 +43,7 @@ void main() {
// 0 12345678 9 101234567 18 90123456 27 // 0 12345678 9 101234567 18 90123456 27
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
TextSpan textSpan = painter.text as TextSpan; TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 28); expect(textSpan.text!.length, 28);
painter.layout(); painter.layout();
@ -127,7 +127,7 @@ void main() {
// The list is currently in the wrong order (so selection boxes will paint in the wrong order). // The list is currently in the wrong order (so selection boxes will paint in the wrong order).
); );
textSpan = painter.text as TextSpan; textSpan = painter.text! as TextSpan;
final List<List<TextBox>> list = <List<TextBox>>[ final List<List<TextBox>> list = <List<TextBox>>[
for (int index = 0; index < textSpan.text!.length; index += 1) for (int index = 0; index < textSpan.text!.length; index += 1)
painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1)), painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1)),
@ -175,7 +175,7 @@ void main() {
// 0 12345678 9 101234567 18 90123456 27 // 0 12345678 9 101234567 18 90123456 27
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
final TextSpan textSpan = painter.text as TextSpan; final TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 28); expect(textSpan.text!.length, 28);
painter.layout(); painter.layout();
@ -265,7 +265,7 @@ void main() {
text: 'A\u05D0', // A, Alef text: 'A\u05D0', // A, Alef
style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0),
); );
final TextSpan textSpan = painter.text as TextSpan; final TextSpan textSpan = painter.text! as TextSpan;
expect(textSpan.text!.length, 2); expect(textSpan.text!.length, 2);
painter.layout(maxWidth: 10.0); painter.layout(maxWidth: 10.0);

View File

@ -20,7 +20,7 @@ void main() {
child: child = RenderSizedBox(const Size(100.0, 100.0)), child: child = RenderSizedBox(const Size(100.0, 100.0)),
), ),
); );
final BoxParentData childParentData = child.parentData as BoxParentData; final BoxParentData childParentData = child.parentData! as BoxParentData;
layout(root, phase: EnginePhase.layout); layout(root, phase: EnginePhase.layout);
expect(childParentData.offset.dx, equals(0.0)); expect(childParentData.offset.dx, equals(0.0));

View File

@ -308,7 +308,7 @@ void main() {
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
); );
layout(paddedBox); layout(paddedBox);
final BoxParentData parentData = coloredBox.parentData as BoxParentData; final BoxParentData parentData = coloredBox.parentData! as BoxParentData;
expect(parentData.offset.dx, isNot(equals(0.0))); expect(parentData.offset.dx, isNot(equals(0.0)));
paddedBox.child = null; paddedBox.child = null;
@ -535,7 +535,7 @@ void main() {
), ),
alignment: Alignment.center, alignment: Alignment.center,
); );
final FlexParentData flexParentData = flexible.parentData as FlexParentData; final FlexParentData flexParentData = flexible.parentData! as FlexParentData;
flexParentData.flex = 1; flexParentData.flex = 1;
flexParentData.fit = FlexFit.tight; flexParentData.fit = FlexFit.tight;
@ -559,7 +559,7 @@ void main() {
), ),
alignment: Alignment.center, alignment: Alignment.center,
); );
final FlexParentData flexParentData = flexible.parentData as FlexParentData; final FlexParentData flexParentData = flexible.parentData! as FlexParentData;
flexParentData.flex = 1; flexParentData.flex = 1;
flexParentData.fit = FlexFit.tight; flexParentData.fit = FlexFit.tight;

View File

@ -82,7 +82,7 @@ void main() {
flexible, flexible,
], ],
); );
final FlexParentData flexParentData = flexible.parentData as FlexParentData; final FlexParentData flexParentData = flexible.parentData! as FlexParentData;
flexParentData.flex = 1; flexParentData.flex = 1;
const BoxConstraints viewport = BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); const BoxConstraints viewport = BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
layout(flex, constraints: viewport); layout(flex, constraints: viewport);
@ -105,7 +105,7 @@ void main() {
flexible, flexible,
], ],
); );
final FlexParentData flexParentData = flexible.parentData as FlexParentData; final FlexParentData flexParentData = flexible.parentData! as FlexParentData;
flexParentData.flex = 1; flexParentData.flex = 1;
const BoxConstraints viewport = BoxConstraints(maxHeight: 100.0, maxWidth: 100.0); const BoxConstraints viewport = BoxConstraints(maxHeight: 100.0, maxWidth: 100.0);
layout(flex, constraints: viewport); layout(flex, constraints: viewport);
@ -165,7 +165,7 @@ void main() {
expect(box2.size.width, equals(0.0)); expect(box2.size.width, equals(0.0));
expect(box2.size.height, equals(0.0)); expect(box2.size.height, equals(0.0));
final FlexParentData box2ParentData = box2.parentData as FlexParentData; final FlexParentData box2ParentData = box2.parentData! as FlexParentData;
box2ParentData.flex = 1; box2ParentData.flex = 1;
flex.markNeedsLayout(); flex.markNeedsLayout();
pumpFrame(); pumpFrame();
@ -180,7 +180,7 @@ void main() {
final RenderDecoratedBox box2 = RenderDecoratedBox(decoration: const BoxDecoration()); final RenderDecoratedBox box2 = RenderDecoratedBox(decoration: const BoxDecoration());
final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr); final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr);
flex.setupParentData(box2); flex.setupParentData(box2);
final FlexParentData box2ParentData = box2.parentData as FlexParentData; final FlexParentData box2ParentData = box2.parentData! as FlexParentData;
box2ParentData.flex = 2; box2ParentData.flex = 2;
flex.addAll(<RenderBox>[box1, box2]); flex.addAll(<RenderBox>[box1, box2]);
layout(flex, constraints: const BoxConstraints( layout(flex, constraints: const BoxConstraints(
@ -216,7 +216,7 @@ void main() {
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0), minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0),
); );
Offset getOffset(RenderBox box) { Offset getOffset(RenderBox box) {
final FlexParentData parentData = box.parentData as FlexParentData; final FlexParentData parentData = box.parentData! as FlexParentData;
return parentData.offset; return parentData.offset;
} }
expect(getOffset(box1).dx, equals(50.0)); expect(getOffset(box1).dx, equals(50.0));
@ -246,7 +246,7 @@ void main() {
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0), minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0),
); );
Offset getOffset(RenderBox box) { Offset getOffset(RenderBox box) {
final FlexParentData parentData = box.parentData as FlexParentData; final FlexParentData parentData = box.parentData! as FlexParentData;
return parentData.offset; return parentData.offset;
} }
expect(getOffset(box1).dx, equals(0.0)); expect(getOffset(box1).dx, equals(0.0));
@ -257,7 +257,7 @@ void main() {
expect(box3.size.width, equals(100.0)); expect(box3.size.width, equals(100.0));
void setFit(RenderBox box, FlexFit fit) { void setFit(RenderBox box, FlexFit fit) {
final FlexParentData parentData = box.parentData as FlexParentData; final FlexParentData parentData = box.parentData! as FlexParentData;
parentData.flex = 1; parentData.flex = 1;
parentData.fit = fit; parentData.fit = fit;
} }
@ -298,7 +298,7 @@ void main() {
minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0), minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0),
); );
Offset getOffset(RenderBox box) { Offset getOffset(RenderBox box) {
final FlexParentData parentData = box.parentData as FlexParentData; final FlexParentData parentData = box.parentData! as FlexParentData;
return parentData.offset; return parentData.offset;
} }
expect(getOffset(box1).dx, equals(0.0)); expect(getOffset(box1).dx, equals(0.0));
@ -310,7 +310,7 @@ void main() {
expect(flex.size.width, equals(300.0)); expect(flex.size.width, equals(300.0));
void setFit(RenderBox box, FlexFit fit) { void setFit(RenderBox box, FlexFit fit) {
final FlexParentData parentData = box.parentData as FlexParentData; final FlexParentData parentData = box.parentData! as FlexParentData;
parentData.flex = 1; parentData.flex = 1;
parentData.fit = fit; parentData.fit = fit;
} }
@ -360,7 +360,7 @@ void main() {
flex.addAll(<RenderBox>[box1, box2, box3]); flex.addAll(<RenderBox>[box1, box2, box3]);
layout(parent); layout(parent);
expect(flex.size, const Size(300.0, 100.0)); expect(flex.size, const Size(300.0, 100.0));
final FlexParentData box2ParentData = box2.parentData as FlexParentData; final FlexParentData box2ParentData = box2.parentData! as FlexParentData;
box2ParentData.flex = 1; box2ParentData.flex = 1;
box2ParentData.fit = FlexFit.loose; box2ParentData.fit = FlexFit.loose;
flex.markNeedsLayout(); flex.markNeedsLayout();
@ -399,7 +399,7 @@ void main() {
child: flex, child: flex,
); );
flex.addAll(<RenderBox>[box1, box2, box3]); flex.addAll(<RenderBox>[box1, box2, box3]);
final FlexParentData box2ParentData = box2.parentData as FlexParentData; final FlexParentData box2ParentData = box2.parentData! as FlexParentData;
box2ParentData.flex = 1; box2ParentData.flex = 1;
final List<dynamic> exceptions = <dynamic>[]; final List<dynamic> exceptions = <dynamic>[];
layout(parent, onErrors: () { layout(parent, onErrors: () {
@ -426,7 +426,7 @@ void main() {
child: flex, child: flex,
); );
flex.addAll(<RenderBox>[box1, box2, box3]); flex.addAll(<RenderBox>[box1, box2, box3]);
final FlexParentData box2ParentData = box2.parentData as FlexParentData; final FlexParentData box2ParentData = box2.parentData! as FlexParentData;
box2ParentData.flex = 1; box2ParentData.flex = 1;
box2ParentData.fit = FlexFit.loose; box2ParentData.fit = FlexFit.loose;
final List<dynamic> exceptions = <dynamic>[]; final List<dynamic> exceptions = <dynamic>[];

View File

@ -34,7 +34,7 @@ class RealRoot extends AbstractNode {
} }
@override @override
PipelineOwner get owner => super.owner as PipelineOwner; PipelineOwner? get owner => super.owner as PipelineOwner?;
void layout() { void layout() {
child.layout(BoxConstraints.tight(const Size(500.0, 500.0))); child.layout(BoxConstraints.tight(const Size(500.0, 500.0)));

View File

@ -102,37 +102,37 @@ void main() {
test('PaintingContext.pushClipRect reuses the layer', () { test('PaintingContext.pushClipRect reuses the layer', () {
_testPaintingContextLayerReuse<ClipRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<ClipRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipRect(true, offset, Rect.zero, painter, oldLayer: oldLayer as ClipRectLayer); return context.pushClipRect(true, offset, Rect.zero, painter, oldLayer: oldLayer as ClipRectLayer?);
}); });
}); });
test('PaintingContext.pushClipRRect reuses the layer', () { test('PaintingContext.pushClipRRect reuses the layer', () {
_testPaintingContextLayerReuse<ClipRRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<ClipRRectLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipRRect(true, offset, Rect.zero, RRect.fromRectAndRadius(Rect.zero, const Radius.circular(1.0)), painter, oldLayer: oldLayer as ClipRRectLayer); return context.pushClipRRect(true, offset, Rect.zero, RRect.fromRectAndRadius(Rect.zero, const Radius.circular(1.0)), painter, oldLayer: oldLayer as ClipRRectLayer?);
}); });
}); });
test('PaintingContext.pushClipPath reuses the layer', () { test('PaintingContext.pushClipPath reuses the layer', () {
_testPaintingContextLayerReuse<ClipPathLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<ClipPathLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushClipPath(true, offset, Rect.zero, Path(), painter, oldLayer: oldLayer as ClipPathLayer); return context.pushClipPath(true, offset, Rect.zero, Path(), painter, oldLayer: oldLayer as ClipPathLayer?);
}); });
}); });
test('PaintingContext.pushColorFilter reuses the layer', () { test('PaintingContext.pushColorFilter reuses the layer', () {
_testPaintingContextLayerReuse<ColorFilterLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<ColorFilterLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushColorFilter(offset, const ColorFilter.mode(Color.fromRGBO(0, 0, 0, 1.0), BlendMode.clear), painter, oldLayer: oldLayer as ColorFilterLayer); return context.pushColorFilter(offset, const ColorFilter.mode(Color.fromRGBO(0, 0, 0, 1.0), BlendMode.clear), painter, oldLayer: oldLayer as ColorFilterLayer?);
}); });
}); });
test('PaintingContext.pushTransform reuses the layer', () { test('PaintingContext.pushTransform reuses the layer', () {
_testPaintingContextLayerReuse<TransformLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<TransformLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushTransform(true, offset, Matrix4.identity(), painter, oldLayer: oldLayer as TransformLayer); return context.pushTransform(true, offset, Matrix4.identity(), painter, oldLayer: oldLayer as TransformLayer?);
}); });
}); });
test('PaintingContext.pushOpacity reuses the layer', () { test('PaintingContext.pushOpacity reuses the layer', () {
_testPaintingContextLayerReuse<OpacityLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) { _testPaintingContextLayerReuse<OpacityLayer>((PaintingContextCallback painter, PaintingContext context, Offset offset, Layer? oldLayer) {
return context.pushOpacity(offset, 100, painter, oldLayer: oldLayer as OpacityLayer); return context.pushOpacity(offset, 100, painter, oldLayer: oldLayer as OpacityLayer?);
}); });
}); });
} }

View File

@ -230,7 +230,7 @@ void main() {
expect(getPixel(0, 0), equals(0x00000080)); expect(getPixel(0, 0), equals(0x00000080));
expect(getPixel(image.width - 1, 0 ), equals(0xffffffff)); expect(getPixel(image.width - 1, 0 ), equals(0xffffffff));
final OffsetLayer layer = boundary.debugLayer as OffsetLayer; final OffsetLayer layer = boundary.debugLayer! as OffsetLayer;
image = await layer.toImage(Offset.zero & const Size(20.0, 20.0)); image = await layer.toImage(Offset.zero & const Size(20.0, 20.0));
expect(image.width, equals(20)); expect(image.width, equals(20));

View File

@ -912,7 +912,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
RenderSliverList createRenderSliverList() { RenderSliverList createRenderSliverList() {
assert(_renderObject == null); assert(_renderObject == null);
_renderObject = RenderSliverList(childManager: this); _renderObject = RenderSliverList(childManager: this);
return _renderObject as RenderSliverList; return _renderObject! as RenderSliverList;
} }
RenderSliverFixedExtentList createRenderSliverFixedExtentList() { RenderSliverFixedExtentList createRenderSliverFixedExtentList() {
@ -921,7 +921,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
childManager: this, childManager: this,
itemExtent: 100.0, itemExtent: 100.0,
); );
return _renderObject as RenderSliverFixedExtentList; return _renderObject! as RenderSliverFixedExtentList;
} }
RenderSliverGrid createRenderSliverGrid() { RenderSliverGrid createRenderSliverGrid() {
@ -933,7 +933,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
childAspectRatio: 4.0, childAspectRatio: 4.0,
), ),
); );
return _renderObject as RenderSliverGrid; return _renderObject! as RenderSliverGrid;
} }
int? _currentlyUpdatingChildIndex; int? _currentlyUpdatingChildIndex;
@ -973,7 +973,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override @override
void didAdoptChild(RenderBox child) { void didAdoptChild(RenderBox child) {
assert(_currentlyUpdatingChildIndex != null); assert(_currentlyUpdatingChildIndex != null);
final SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData; final SliverMultiBoxAdaptorParentData childParentData = child.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.index = _currentlyUpdatingChildIndex; childParentData.index = _currentlyUpdatingChildIndex;
} }

View File

@ -56,7 +56,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
_renderObject = RenderSliverFillViewport( _renderObject = RenderSliverFillViewport(
childManager: this, childManager: this,
); );
return _renderObject as RenderSliverFillViewport; return _renderObject! as RenderSliverFillViewport;
} }
int? _currentlyUpdatingChildIndex; int? _currentlyUpdatingChildIndex;
@ -96,7 +96,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override @override
void didAdoptChild(RenderBox child) { void didAdoptChild(RenderBox child) {
assert(_currentlyUpdatingChildIndex != null); assert(_currentlyUpdatingChildIndex != null);
final SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData; final SliverMultiBoxAdaptorParentData childParentData = child.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.index = _currentlyUpdatingChildIndex; childParentData.index = _currentlyUpdatingChildIndex;
} }

View File

@ -59,7 +59,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager {
@override @override
void didAdoptChild(RenderBox child) { void didAdoptChild(RenderBox child) {
assert(_currentlyUpdatingChildIndex != null); assert(_currentlyUpdatingChildIndex != null);
final SliverMultiBoxAdaptorParentData childParentData = child.parentData as SliverMultiBoxAdaptorParentData; final SliverMultiBoxAdaptorParentData childParentData = child.parentData! as SliverMultiBoxAdaptorParentData;
childParentData.index = _currentlyUpdatingChildIndex; childParentData.index = _currentlyUpdatingChildIndex;
} }
@ -288,7 +288,7 @@ void main() {
); );
layout(root); layout(root);
final SliverMultiBoxAdaptorParentData parentData = a.parentData as SliverMultiBoxAdaptorParentData; final SliverMultiBoxAdaptorParentData parentData = a.parentData! as SliverMultiBoxAdaptorParentData;
parentData.layoutOffset = 0.001; parentData.layoutOffset = 0.001;
root.offset = ViewportOffset.fixed(900.0); root.offset = ViewportOffset.fixed(900.0);
@ -323,7 +323,7 @@ void main() {
); );
layout(root); layout(root);
final SliverMultiBoxAdaptorParentData parentData = a.parentData as SliverMultiBoxAdaptorParentData; final SliverMultiBoxAdaptorParentData parentData = a.parentData! as SliverMultiBoxAdaptorParentData;
// Simulate double precision error. // Simulate double precision error.
parentData.layoutOffset = -0.0000000000001; parentData.layoutOffset = -0.0000000000001;

View File

@ -288,11 +288,11 @@ void main() {
expect(root.size.width, equals(800.0)); expect(root.size.width, equals(800.0));
expect(root.size.height, equals(600.0)); expect(root.size.height, equals(600.0));
final RenderSliver sliverA = a.parent as RenderSliver; final RenderSliver sliverA = a.parent! as RenderSliver;
final RenderSliver sliverB = b.parent as RenderSliver; final RenderSliver sliverB = b.parent! as RenderSliver;
final RenderSliver sliverC = c.parent as RenderSliver; final RenderSliver sliverC = c.parent! as RenderSliver;
final RenderSliver sliverD = d.parent as RenderSliver; final RenderSliver sliverD = d.parent! as RenderSliver;
final RenderSliver sliverE = e.parent as RenderSliver; final RenderSliver sliverE = e.parent! as RenderSliver;
expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0));
expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(400.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(400.0, 0.0));

View File

@ -30,7 +30,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <RenderBox>[red, green], children: <RenderBox>[red, green],
); );
final StackParentData greenParentData = green.parentData as StackParentData; final StackParentData greenParentData = green.parentData! as StackParentData;
greenParentData greenParentData
..top = 0.0 ..top = 0.0
..right = 0.0 ..right = 0.0
@ -79,7 +79,7 @@ void main() {
clipBehavior: clip, clipBehavior: clip,
); );
{ // Make sure that the child is positioned so the stack will consider it as overflowed. { // Make sure that the child is positioned so the stack will consider it as overflowed.
final StackParentData parentData = child.parentData as StackParentData; final StackParentData parentData = child.parentData! as StackParentData;
parentData.left = parentData.right = 0; parentData.left = parentData.right = 0;
} }
layout(stack, constraints: viewport, phase: EnginePhase.composite, onErrors: expectOverflowedErrors); layout(stack, constraints: viewport, phase: EnginePhase.composite, onErrors: expectOverflowedErrors);

View File

@ -45,7 +45,7 @@ void main() {
), ),
); );
final RenderDecoratedBox box = key.currentContext!.findRenderObject() as RenderDecoratedBox; final RenderDecoratedBox box = key.currentContext!.findRenderObject()! as RenderDecoratedBox;
actualDecoration = box.decoration as BoxDecoration; actualDecoration = box.decoration as BoxDecoration;
expect(actualDecoration.color, equals(decorationA.color)); expect(actualDecoration.color, equals(decorationA.color));

View File

@ -42,12 +42,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -69,17 +69,17 @@ void main() {
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0); const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0); const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep); expect(box, hasAGoodToStringDeep);
@ -126,12 +126,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -155,17 +155,17 @@ void main() {
const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0); const Offset first = Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0); const Offset last = Offset(37.0 + 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep); expect(box, hasAGoodToStringDeep);
@ -212,12 +212,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -241,17 +241,17 @@ void main() {
const Offset first = Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0); const Offset first = Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0);
const Offset last = Offset(800.0 - 37.0 - 59.0 / 2.0, 31.0 + 71.0 / 2.0); const Offset last = Offset(800.0 - 37.0 - 59.0 / 2.0, 31.0 + 71.0 / 2.0);
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(first));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(Offset.lerp(first, last, 0.5)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last)); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(last));
expect(box, hasAGoodToStringDeep); expect(box, hasAGoodToStringDeep);
@ -296,12 +296,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -320,12 +320,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -344,17 +344,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
}); });
@ -379,12 +379,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -403,17 +403,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
}); });
@ -440,12 +440,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -466,12 +466,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -492,17 +492,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(150.0, 150.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(200.0, 200.0)));
}); });
@ -529,12 +529,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -555,17 +555,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(350.0, 150.0)));
}); });
@ -592,12 +592,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -618,12 +618,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -644,17 +644,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(650.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(650.0, 150.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(600.0, 200.0)));
}); });
@ -681,12 +681,12 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0)));
await tester.pumpWidget( await tester.pumpWidget(
@ -707,17 +707,17 @@ void main() {
), ),
); );
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 50.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 50.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 100.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 100.0)));
await tester.pump(const Duration(seconds: 1)); await tester.pump(const Duration(seconds: 1));
box = key.currentContext!.findRenderObject() as RenderBox; box = key.currentContext!.findRenderObject()! as RenderBox;
expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 150.0))); expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(450.0, 150.0)));
}); });

View File

@ -25,11 +25,10 @@ Future<ui.Image> captureImage(Element element) {
assert(element.renderObject != null); assert(element.renderObject != null);
RenderObject renderObject = element.renderObject!; RenderObject renderObject = element.renderObject!;
while (!renderObject.isRepaintBoundary) { while (!renderObject.isRepaintBoundary) {
renderObject = renderObject.parent as RenderObject; renderObject = renderObject.parent! as RenderObject;
assert(renderObject != null);
} }
assert(!renderObject.debugNeedsPaint); assert(!renderObject.debugNeedsPaint);
final OffsetLayer layer = renderObject.debugLayer as OffsetLayer; final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer;
return layer.toImage(renderObject.paintBounds); return layer.toImage(renderObject.paintBounds);
} }

View File

@ -83,8 +83,7 @@ RenderObject _findRepaintBoundary(Element element) {
assert(element.renderObject != null); assert(element.renderObject != null);
RenderObject renderObject = element.renderObject!; RenderObject renderObject = element.renderObject!;
while (!renderObject.isRepaintBoundary) { while (!renderObject.isRepaintBoundary) {
renderObject = renderObject.parent as RenderObject; renderObject = renderObject.parent! as RenderObject;
assert(renderObject != null);
} }
return renderObject; return renderObject;
} }

View File

@ -198,7 +198,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
Future<Evaluation> evaluate(WidgetTester tester) async { Future<Evaluation> evaluate(WidgetTester tester) async {
final SemanticsNode root = tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!; final SemanticsNode root = tester.binding.pipelineOwner.semanticsOwner!.rootSemanticsNode!;
final RenderView renderView = tester.binding.renderView; final RenderView renderView = tester.binding.renderView;
final OffsetLayer layer = renderView.debugLayer as OffsetLayer; final OffsetLayer layer = renderView.debugLayer! as OffsetLayer;
ui.Image? image; ui.Image? image;
final ByteData byteData = (await tester.binding.runAsync<ByteData?>(() async { final ByteData byteData = (await tester.binding.runAsync<ByteData?>(() async {
// Needs to be the same pixel ratio otherwise our dimensions won't match the // Needs to be the same pixel ratio otherwise our dimensions won't match the
@ -370,7 +370,7 @@ class CustomMinimumContrastGuideline extends AccessibilityGuideline {
// Obtain rendered image. // Obtain rendered image.
final RenderView renderView = tester.binding.renderView; final RenderView renderView = tester.binding.renderView;
final OffsetLayer layer = renderView.debugLayer as OffsetLayer; final OffsetLayer layer = renderView.debugLayer! as OffsetLayer;
ui.Image? image; ui.Image? image;
final ByteData byteData = (await tester.binding.runAsync<ByteData?>(() async { final ByteData byteData = (await tester.binding.runAsync<ByteData?>(() async {
// Needs to be the same pixel ratio otherwise our dimensions won't match the // Needs to be the same pixel ratio otherwise our dimensions won't match the
@ -383,7 +383,7 @@ class CustomMinimumContrastGuideline extends AccessibilityGuideline {
// How to evaluate a single element. // How to evaluate a single element.
Evaluation evaluateElement(Element element) { Evaluation evaluateElement(Element element) {
final RenderBox renderObject = element.renderObject as RenderBox; final RenderBox renderObject = element.renderObject! as RenderBox;
final Rect originalPaintBounds = renderObject.paintBounds; final Rect originalPaintBounds = renderObject.paintBounds;

View File

@ -205,7 +205,7 @@ abstract class WidgetController {
/// * Use [renderObjectList] if you expect to match several render objects and want all of them. /// * Use [renderObjectList] if you expect to match several render objects and want all of them.
T renderObject<T extends RenderObject>(Finder finder) { T renderObject<T extends RenderObject>(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return finder.evaluate().single.renderObject as T; return finder.evaluate().single.renderObject! as T;
} }
/// The render object of the first matching widget according to a /// The render object of the first matching widget according to a
@ -216,7 +216,7 @@ abstract class WidgetController {
/// * Use [renderObject] if you only expect to match one render object. /// * Use [renderObject] if you only expect to match one render object.
T firstRenderObject<T extends RenderObject>(Finder finder) { T firstRenderObject<T extends RenderObject>(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return finder.evaluate().first.renderObject as T; return finder.evaluate().first.renderObject! as T;
} }
/// The render objects of the matching widgets in the widget tree. /// The render objects of the matching widgets in the widget tree.
@ -226,7 +226,7 @@ abstract class WidgetController {
Iterable<T> renderObjectList<T extends RenderObject>(Finder finder) { Iterable<T> renderObjectList<T extends RenderObject>(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
return finder.evaluate().map<T>((Element element) { return finder.evaluate().map<T>((Element element) {
final T result = element.renderObject as T; final T result = element.renderObject! as T;
return result; return result;
}); });
} }
@ -812,8 +812,7 @@ abstract class WidgetController {
Offset _getElementPoint(Finder finder, Offset sizeToPoint(Size size)) { Offset _getElementPoint(Finder finder, Offset sizeToPoint(Size size)) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
final Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
final RenderBox box = element.renderObject as RenderBox; final RenderBox box = element.renderObject! as RenderBox;
assert(box != null);
return box.localToGlobal(sizeToPoint(box.size)); return box.localToGlobal(sizeToPoint(box.size));
} }
@ -822,8 +821,7 @@ abstract class WidgetController {
Size getSize(Finder finder) { Size getSize(Finder finder) {
TestAsyncUtils.guardSync(); TestAsyncUtils.guardSync();
final Element element = finder.evaluate().single; final Element element = finder.evaluate().single;
final RenderBox box = element.renderObject as RenderBox; final RenderBox box = element.renderObject! as RenderBox;
assert(box != null);
return box.size; return box.size;
} }

View File

@ -516,8 +516,7 @@ class _HitTestableFinder extends ChainedFinder {
@override @override
Iterable<Element> filter(Iterable<Element> parentCandidates) sync* { Iterable<Element> filter(Iterable<Element> parentCandidates) sync* {
for (final Element candidate in parentCandidates) { for (final Element candidate in parentCandidates) {
final RenderBox box = candidate.renderObject as RenderBox; final RenderBox box = candidate.renderObject! as RenderBox;
assert(box != null);
final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size)); final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size));
final HitTestResult hitResult = HitTestResult(); final HitTestResult hitResult = HitTestResult();
WidgetsBinding.instance!.hitTest(hitResult, absoluteOffset); WidgetsBinding.instance!.hitTest(hitResult, absoluteOffset);

View File

@ -1362,7 +1362,7 @@ class _RendersOnPhysicalModel extends _MatchRenderObject<RenderPhysicalShape, Re
bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderPhysicalShape renderObject) { bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderPhysicalShape renderObject) {
if (renderObject.clipper.runtimeType != ShapeBorderClipper) if (renderObject.clipper.runtimeType != ShapeBorderClipper)
return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}'); return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}');
final ShapeBorderClipper shapeClipper = renderObject.clipper as ShapeBorderClipper; final ShapeBorderClipper shapeClipper = renderObject.clipper! as ShapeBorderClipper;
if (borderRadius != null && !assertRoundedRectangle(shapeClipper, borderRadius!, matchState)) if (borderRadius != null && !assertRoundedRectangle(shapeClipper, borderRadius!, matchState))
return false; return false;
@ -1430,7 +1430,7 @@ class _RendersOnPhysicalShape extends _MatchRenderObject<RenderPhysicalShape, Re
bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderPhysicalShape renderObject) { bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderPhysicalShape renderObject) {
if (renderObject.clipper.runtimeType != ShapeBorderClipper) if (renderObject.clipper.runtimeType != ShapeBorderClipper)
return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}'); return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}');
final ShapeBorderClipper shapeClipper = renderObject.clipper as ShapeBorderClipper; final ShapeBorderClipper shapeClipper = renderObject.clipper! as ShapeBorderClipper;
if (shapeClipper.shape != shape) if (shapeClipper.shape != shape)
return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}'); return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}');
@ -1469,7 +1469,7 @@ class _ClipsWithBoundingRect extends _MatchRenderObject<RenderClipPath, RenderCl
bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) { bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) {
if (renderObject.clipper.runtimeType != ShapeBorderClipper) if (renderObject.clipper.runtimeType != ShapeBorderClipper)
return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}'); return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}');
final ShapeBorderClipper shapeClipper = renderObject.clipper as ShapeBorderClipper; final ShapeBorderClipper shapeClipper = renderObject.clipper! as ShapeBorderClipper;
if (shapeClipper.shape.runtimeType != RoundedRectangleBorder) if (shapeClipper.shape.runtimeType != RoundedRectangleBorder)
return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}'); return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}');
final RoundedRectangleBorder border = shapeClipper.shape as RoundedRectangleBorder; final RoundedRectangleBorder border = shapeClipper.shape as RoundedRectangleBorder;
@ -1504,7 +1504,7 @@ class _ClipsWithBoundingRRect extends _MatchRenderObject<RenderClipPath, RenderC
bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) { bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) {
if (renderObject.clipper.runtimeType != ShapeBorderClipper) if (renderObject.clipper.runtimeType != ShapeBorderClipper)
return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}'); return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}');
final ShapeBorderClipper shapeClipper = renderObject.clipper as ShapeBorderClipper; final ShapeBorderClipper shapeClipper = renderObject.clipper! as ShapeBorderClipper;
if (shapeClipper.shape.runtimeType != RoundedRectangleBorder) if (shapeClipper.shape.runtimeType != RoundedRectangleBorder)
return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}'); return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}');
final RoundedRectangleBorder border = shapeClipper.shape as RoundedRectangleBorder; final RoundedRectangleBorder border = shapeClipper.shape as RoundedRectangleBorder;
@ -1527,7 +1527,7 @@ class _ClipsWithShapeBorder extends _MatchRenderObject<RenderClipPath, RenderCli
bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) { bool renderObjectMatchesM(Map<dynamic, dynamic> matchState, RenderClipPath renderObject) {
if (renderObject.clipper.runtimeType != ShapeBorderClipper) if (renderObject.clipper.runtimeType != ShapeBorderClipper)
return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}'); return failWithDescription(matchState, 'clipper was: ${renderObject.clipper}');
final ShapeBorderClipper shapeClipper = renderObject.clipper as ShapeBorderClipper; final ShapeBorderClipper shapeClipper = renderObject.clipper! as ShapeBorderClipper;
if (shapeClipper.shape != shape) if (shapeClipper.shape != shape)
return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}'); return failWithDescription(matchState, 'shape was: ${shapeClipper.shape}');
return true; return true;

View File

@ -681,7 +681,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
'therefore no restoration data has been collected to restore from. Did you forget to wrap ' 'therefore no restoration data has been collected to restore from. Did you forget to wrap '
'your widget tree in a RootRestorationScope?', 'your widget tree in a RootRestorationScope?',
); );
final Widget widget = (binding.renderViewElement as RenderObjectToWidgetElement<RenderObject>).widget.child!; final Widget widget = (binding.renderViewElement! as RenderObjectToWidgetElement<RenderObject>).widget.child!;
final TestRestorationData restorationData = binding.restorationManager.restorationData; final TestRestorationData restorationData = binding.restorationManager.restorationData;
runApp(Container(key: UniqueKey())); runApp(Container(key: UniqueKey()));
await pump(); await pump();