Commit 3b702448 authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Do not paint a RenderFittedBox with an empty size (#7489)

If the size is empty, then _updatePaintData will produce an invalid transform
that yields a NaN canvas bounds rectangle

Fixes https://github.com/flutter/flutter/issues/7431
parent 113fd6cb
......@@ -1573,6 +1573,8 @@ class RenderFittedBox extends RenderProxyBox {
@override
void paint(PaintingContext context, Offset offset) {
if (size.isEmpty)
return;
_updatePaintData();
if (child != null) {
if (_hasVisualOverflow)
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/rendering.dart';
import 'package:test/test.dart';
import 'rendering_tester.dart';
void main() {
test('RenderFittedBox paint', () {
bool painted;
RenderFittedBox makeFittedBox() {
return new RenderFittedBox(
child: new RenderCustomPaint(
painter: new TestCallbackPainter(
onPaint: () { painted = true; }
),
),
);
}
painted = false;
layout(makeFittedBox(), phase: EnginePhase.paint);
expect(painted, equals(true));
// The RenderFittedBox should not paint if it is empty.
painted = false;
layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint);
expect(painted, equals(false));
});
}
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