mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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
This commit is contained in:
parent
113fd6cb52
commit
3b702448fd
@ -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)
|
||||
|
||||
32
packages/flutter/test/rendering/proxy_box_test.dart
Normal file
32
packages/flutter/test/rendering/proxy_box_test.dart
Normal file
@ -0,0 +1,32 @@
|
||||
// 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));
|
||||
});
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user