Remove NavigationToolbar condition that leading widget cannot be larger than 1/3 the total space available. (#112548)
This commit is contained in:
@@ -106,7 +106,7 @@ class _ToolbarLayout extends MultiChildLayoutDelegate {
|
||||
|
||||
if (hasChild(_ToolbarSlot.leading)) {
|
||||
final BoxConstraints constraints = BoxConstraints(
|
||||
maxWidth: size.width / 3.0, // The leading widget shouldn't take up more than 1/3 of the space.
|
||||
maxWidth: size.width,
|
||||
minHeight: size.height, // The height should be exactly the height of the bar.
|
||||
maxHeight: size.height,
|
||||
);
|
||||
|
||||
@@ -3680,4 +3680,34 @@ void main() {
|
||||
await tester.pumpWidget(buildApp());
|
||||
expect(tester.getTopLeft(title).dx, 16.0);
|
||||
});
|
||||
|
||||
testWidgets('AppBar leading widget can take up arbitrary space', (WidgetTester tester) async {
|
||||
final Key leadingKey = UniqueKey();
|
||||
final Key titleKey = UniqueKey();
|
||||
late double leadingWidth;
|
||||
|
||||
Widget buildApp() {
|
||||
return MaterialApp(
|
||||
home: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
leadingWidth = constraints.maxWidth / 2;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: Container(
|
||||
key: leadingKey,
|
||||
width: leadingWidth,
|
||||
),
|
||||
leadingWidth: leadingWidth,
|
||||
title: Text('Title', key: titleKey),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildApp());
|
||||
expect(tester.getTopLeft(find.byKey(titleKey)).dx, leadingWidth + 16.0);
|
||||
expect(tester.getSize(find.byKey(leadingKey)).width, leadingWidth);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user