Commit e7c2571b authored by Jason Simmons's avatar Jason Simmons Committed by GitHub

Handle empty sizes in AppBar's toolbar layout (#6894)

parent cac54594
......@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
......@@ -58,7 +60,7 @@ class _ToolbarLayout extends MultiChildLayoutDelegate {
}
if (hasChild(_ToolbarSlot.title)) {
final double maxWidth = size.width - kTitleLeft - actionsWidth;
final double maxWidth = math.max(size.width - kTitleLeft - actionsWidth, 0.0);
final BoxConstraints constraints = new BoxConstraints.loose(size).copyWith(maxWidth: maxWidth);
final Size titleSize = layoutChild(_ToolbarSlot.title, constraints);
final double titleY = (size.height - titleSize.height) / 2.0;
......
......@@ -179,4 +179,22 @@ void main() {
expect(tester.getSize(title).width, equals(620.0));
});
testWidgets('AppBar render at zero size', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(
child: new Container(
height: 0.0,
width: 0.0,
child: new Scaffold(
appBar: new AppBar(
title: new Text('X')
)
)
)
)
);
Finder title = find.text('X');
expect(tester.getSize(title).isEmpty, isTrue);
});
}
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