mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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
This commit is contained in:
parent
3d7a4eed44
commit
a13320253c
@ -971,6 +971,10 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There's no point in drawing the children if we're empty.
|
||||||
|
if (size.isEmpty)
|
||||||
|
return;
|
||||||
|
|
||||||
// We have overflow. Clip it.
|
// We have overflow. Clip it.
|
||||||
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
|
context.pushClipRect(needsCompositing, offset, Offset.zero & size, defaultPaint);
|
||||||
|
|
||||||
|
56
packages/flutter/test/rendering/flex_overflow_test.dart
Normal file
56
packages/flutter/test/rendering/flex_overflow_test.dart
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// 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));
|
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
|
||||||
expect(renderBox.size.width, equals(0.0));
|
expect(renderBox.size.width, equals(0.0));
|
||||||
expect(renderBox.size.height, equals(100.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));
|
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
|
||||||
expect(renderBox.size.width, equals(0.0));
|
expect(renderBox.size.width, equals(0.0));
|
||||||
expect(renderBox.size.height, equals(100.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));
|
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
|
||||||
expect(renderBox.size.width, equals(100.0));
|
expect(renderBox.size.width, equals(100.0));
|
||||||
expect(renderBox.size.height, equals(0.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));
|
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
|
||||||
expect(renderBox.size.width, equals(100.0));
|
expect(renderBox.size.width, equals(100.0));
|
||||||
expect(renderBox.size.height, equals(0.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));
|
final RenderBox renderBox = tester.renderObject(find.byKey(childKey));
|
||||||
expect(renderBox.size.width, equals(100.0));
|
expect(renderBox.size.width, equals(100.0));
|
||||||
expect(renderBox.size.height, equals(0.0));
|
expect(renderBox.size.height, equals(0.0));
|
||||||
|
Loading…
Reference in New Issue
Block a user