Unverified Commit e9c1c162 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Fix null child for FittedBox (#86662)

parent 1edd9126
...@@ -2651,11 +2651,11 @@ class RenderFittedBox extends RenderProxyBox { ...@@ -2651,11 +2651,11 @@ class RenderFittedBox extends RenderProxyBox {
@override @override
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
if (size.isEmpty || child!.size.isEmpty) if (child == null || size.isEmpty || child!.size.isEmpty)
return; return;
_updatePaintData(); _updatePaintData();
if (child != null) { assert(child != null);
if (_hasVisualOverflow! && clipBehavior != Clip.none) if (_hasVisualOverflow! && clipBehavior != Clip.none) {
layer = context.pushClipRect( layer = context.pushClipRect(
needsCompositing, needsCompositing,
offset, offset,
...@@ -2664,7 +2664,7 @@ class RenderFittedBox extends RenderProxyBox { ...@@ -2664,7 +2664,7 @@ class RenderFittedBox extends RenderProxyBox {
oldLayer: layer is ClipRectLayer ? layer! as ClipRectLayer : null, oldLayer: layer is ClipRectLayer ? layer! as ClipRectLayer : null,
clipBehavior: clipBehavior, clipBehavior: clipBehavior,
); );
else } else {
layer = _paintChildWithTransform(context, offset); layer = _paintChildWithTransform(context, offset);
} }
} }
......
...@@ -589,6 +589,24 @@ void main() { ...@@ -589,6 +589,24 @@ void main() {
expect(outsideBox.size.height, 50.0); expect(outsideBox.size.height, 50.0);
}); });
testWidgets('FittedBox without child does not throw', (WidgetTester tester) async {
await tester.pumpWidget(
const Center(
child: SizedBox(
width: 200.0,
height: 200.0,
child: FittedBox(),
),
),
);
expect(find.byType(FittedBox), findsOneWidget);
// Tapping it also should not throw.
await tester.tap(find.byType(FittedBox), warnIfMissed: false);
expect(tester.takeException(), isNull);
});
} }
List<Type> getLayers() { List<Type> getLayers() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment