Commit 932f7cef authored by Adam Barth's avatar Adam Barth Committed by GitHub

Scaffold shouldn't assert with large bottom padding (#8415)

Fixes #8413
parent 87f1487e
......@@ -48,7 +48,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
@override
void performLayout(Size size) {
BoxConstraints looseConstraints = new BoxConstraints.loose(size);
final BoxConstraints looseConstraints = new BoxConstraints.loose(size);
// This part of the layout has the same effect as putting the app bar and
// body in a column and making the body flexible. What's different is that
......@@ -56,8 +56,8 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
// so the app bar's shadow is drawn on top of the body.
final BoxConstraints fullWidthConstraints = looseConstraints.tighten(width: size.width);
final double bottom = math.max(0.0, size.height - padding.bottom);
double contentTop = 0.0;
double bottom = size.height - padding.bottom;
double contentBottom = bottom;
if (hasChild(_ScaffoldSlot.appBar)) {
......@@ -78,10 +78,9 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
}
if (hasChild(_ScaffoldSlot.body)) {
final double bodyHeight = contentBottom - contentTop;
final BoxConstraints bodyConstraints = new BoxConstraints(
maxWidth: fullWidthConstraints.maxWidth,
maxHeight: bodyHeight,
maxHeight: math.max(0.0, contentBottom - contentTop),
);
layoutChild(_ScaffoldSlot.body, bodyConstraints);
positionChild(_ScaffoldSlot.body, new Offset(0.0, contentTop));
......
......@@ -41,6 +41,46 @@ void main() {
expect(bodyBox.size, equals(const Size(800.0, 544.0)));
});
testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async {
Key bodyKey = new UniqueKey();
await tester.pumpWidget(new MediaQuery(
data: new MediaQueryData(
padding: const EdgeInsets.only(bottom: 700.0),
),
child: new Scaffold(
body: new Container(key: bodyKey),
),
));
RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
expect(bodyBox.size, equals(const Size(800.0, 0.0)));
await tester.pumpWidget(new MediaQuery(
data: new MediaQueryData(
padding: const EdgeInsets.only(bottom: 500.0),
),
child: new Scaffold(
body: new Container(key: bodyKey),
),
));
expect(bodyBox.size, equals(const Size(800.0, 100.0)));
await tester.pumpWidget(new MediaQuery(
data: new MediaQueryData(
padding: const EdgeInsets.only(bottom: 580.0),
),
child: new Scaffold(
appBar: new AppBar(
title: new Text('Title'),
),
body: new Container(key: bodyKey),
),
));
expect(bodyBox.size, equals(const Size(800.0, 0.0)));
});
testWidgets('Floating action animation', (WidgetTester tester) async {
await tester.pumpWidget(new Scaffold(
floatingActionButton: new FloatingActionButton(
......
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