Fixed issue for SliverAppBar collapsedHeight (#72300)
diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart
index c7c443f..b57b7a4 100644
--- a/packages/flutter/lib/src/material/app_bar.dart
+++ b/packages/flutter/lib/src/material/app_bar.dart
@@ -1464,7 +1464,7 @@
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 799d00f..af4283c 100644
--- a/packages/flutter/test/material/app_bar_test.dart
+++ b/packages/flutter/test/material/app_bar_test.dart
@@ -2198,6 +2198,25 @@
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(