@@ -586,6 +586,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
586
586
this .leading,
587
587
this .automaticallyImplyLeading = true ,
588
588
this .automaticallyImplyTitle = true ,
589
+ this .alwaysShowMiddle = true ,
589
590
this .previousPageTitle,
590
591
this .middle,
591
592
this .trailing,
@@ -645,13 +646,25 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
645
646
/// This value cannot be null.
646
647
final bool automaticallyImplyTitle;
647
648
649
+ /// Controls whether [middle] widget should always be visible (even in
650
+ /// expanded state).
651
+ ///
652
+ /// If true (default) and [middle] is not null, [middle] widget is always
653
+ /// visible. If false, [middle] widget is visible only in collapsed state if
654
+ /// it is provided.
655
+ ///
656
+ /// This should be set to false if you only want to show [largeTitle] in
657
+ /// expanded state and [middle] in collapsed state.
658
+ final bool alwaysShowMiddle;
659
+
648
660
/// {@macro flutter.cupertino.CupertinoNavigationBar.previousPageTitle}
649
661
final String ? previousPageTitle;
650
662
651
663
/// A widget to place in the middle of the static navigation bar instead of
652
664
/// the [largeTitle] .
653
665
///
654
- /// This widget is visible in both collapsed and expanded states. The text
666
+ /// This widget is visible in both collapsed and expanded states if
667
+ /// [alwaysShowMiddle] is true, otherwise just in collapsed state. The text
655
668
/// supplied in [largeTitle] will no longer appear in collapsed state if a
656
669
/// [middle] widget is provided.
657
670
final Widget ? middle;
@@ -742,7 +755,7 @@ class _CupertinoSliverNavigationBarState extends State<CupertinoSliverNavigation
742
755
transitionBetweenRoutes: widget.transitionBetweenRoutes,
743
756
heroTag: widget.heroTag,
744
757
persistentHeight: _kNavBarPersistentHeight + MediaQuery .of (context).padding.top,
745
- alwaysShowMiddle: widget.middle != null ,
758
+ alwaysShowMiddle: widget.alwaysShowMiddle && widget. middle != null ,
746
759
stretchConfiguration: widget.stretch ? OverScrollHeaderStretchConfiguration () : null ,
747
760
),
748
761
),
0 commit comments