Commit a1332025 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Don't attempt to draw invisible overflow indicator (#12534)

If the flex is empty, there's no space in which to draw the overflow indicator,
so we shouldn't bother trying to draw it.

Fixes #12532
parent 3d7a4eed
......@@ -971,6 +971,10 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
return;
}
// There's no point in drawing the children if we're empty.
if (size.isEmpty)
return;
// We have overflow. Clip it.
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
......
// 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_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
import 'mock_canvas.dart';
void main() {
testWidgets('Flex overflow indicator', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(
child: new Column(
children: <Widget>[
const SizedBox(width: 200.0, height: 200.0),
],
),
),
);
expect(find.byType(Column), isNot(paints..rect()));
await tester.pumpWidget(
new Center(
child: new SizedBox(
height: 100.0,
child: new Column(
children: <Widget>[
const SizedBox(width: 200.0, height: 200.0),
],
),
),
),
);
expect(tester.takeException(), isNotNull);
expect(find.byType(Column), paints..rect());
await tester.pumpWidget(
new Center(
child: new SizedBox(
height: 0.0,
child: new Column(
children: <Widget>[
const SizedBox(width: 200.0, height: 200.0),
],
),
),
),
);
expect(find.byType(Column), isNot(paints..rect()));
});
}
......@@ -384,8 +384,6 @@ void main() {
)
));
expect(tester.takeException(), contains('overflowed'));
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
expect(renderBox.size.width, equals(0.0));
expect(renderBox.size.height, equals(100.0));
......@@ -779,8 +777,6 @@ void main() {
)
));
expect(tester.takeException(), contains('overflowed'));
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
expect(renderBox.size.width, equals(0.0));
expect(renderBox.size.height, equals(100.0));
......
......@@ -302,8 +302,6 @@ void main() {
),
));
expect(tester.takeException(), contains('overflowed'));
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
expect(renderBox.size.width, equals(100.0));
expect(renderBox.size.height, equals(0.0));
......@@ -727,8 +725,6 @@ void main() {
),
));
expect(tester.takeException(), contains('overflowed'));
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
expect(renderBox.size.width, equals(100.0));
expect(renderBox.size.height, equals(0.0));
......@@ -1152,8 +1148,6 @@ void main() {
),
));
expect(tester.takeException(), contains('overflowed'));
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
expect(renderBox.size.width, equals(100.0));
expect(renderBox.size.height, equals(0.0));
......
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