diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index c7c443f12d..b57b7a4960 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -1464,7 +1464,7 @@ class SliverAppBar extends StatefulWidget { assert(toolbarHeight != null), assert(floating || !snap, 'The "snap" argument only makes sense for floating app bars.'), assert(stretchTriggerOffset > 0.0), - assert(collapsedHeight == null || collapsedHeight > toolbarHeight, 'The "collapsedHeight" argument has to be larger than [toolbarHeight].'), + assert(collapsedHeight == null || collapsedHeight >= toolbarHeight, 'The "collapsedHeight" argument has to be larger than or equal to [toolbarHeight].'), super(key: key); /// {@macro flutter.material.appbar.leading} diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 799d00ff02..af4283c1ce 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -2198,6 +2198,25 @@ void main() { expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight); }); + testWidgets('SliverAppBar collapsedHeight', (WidgetTester tester) async { + const double collapsedHeight = 56.0; + + await tester.pumpWidget(buildSliverAppBarApp( + floating: false, + pinned: false, + collapsedHeight: collapsedHeight + )); + + final ScrollController controller = primaryScrollController(tester); + final double initialTabBarHeight = tabBarHeight(tester); + + // Scroll the not-pinned appbar out of view, to its collapsed height. + controller.jumpTo(300.0); + await tester.pump(); + expect(find.byType(SliverAppBar), findsNothing); + expect(appBarHeight(tester), collapsedHeight + initialTabBarHeight); + }); + testWidgets('AppBar respects leadingWidth', (WidgetTester tester) async { const Key key = Key('leading'); await tester.pumpWidget(MaterialApp(