From 11771b2d6106c925eaf742f602398e62c90c78ab Mon Sep 17 00:00:00 2001 From: Ari Weiland Date: Thu, 6 Oct 2022 15:50:18 -0400 Subject: [PATCH] Remove NavigationToolbar condition that leading widget cannot be larger than 1/3 the total space available. (#112548) --- .../lib/src/widgets/navigation_toolbar.dart | 2 +- .../flutter/test/material/app_bar_test.dart | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/widgets/navigation_toolbar.dart b/packages/flutter/lib/src/widgets/navigation_toolbar.dart index 951a1ee86b..c67a7891f0 100644 --- a/packages/flutter/lib/src/widgets/navigation_toolbar.dart +++ b/packages/flutter/lib/src/widgets/navigation_toolbar.dart @@ -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, ); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 0ea45bddfd..bd0f80677c 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -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); + }); }