CupertinoSliverNavigationBar.search constructor

const CupertinoSliverNavigationBar.search({
  1. Key? key,
  2. required Widget searchField,
  3. Widget? largeTitle,
  4. Widget? leading,
  5. bool automaticallyImplyLeading = true,
  6. bool automaticallyImplyTitle = true,
  7. bool alwaysShowMiddle = true,
  8. String? previousPageTitle,
  9. Widget? middle,
  10. Widget? trailing,
  11. Border? border = _kDefaultNavBarBorder,
  12. Color? backgroundColor,
  13. bool automaticBackgroundVisibility = true,
  14. bool enableBackgroundFilterBlur = true,
  15. Brightness? brightness,
  16. EdgeInsetsDirectional? padding,
  17. bool transitionBetweenRoutes = true,
  18. Object heroTag = _defaultHeroTag,
  19. bool stretch = false,
  20. NavigationBarBottomMode? bottomMode = NavigationBarBottomMode.automatic,
  21. ValueChanged<bool>? onSearchableBottomTap,
})

A navigation bar for scrolling lists that integrates a provided search field directly into the navigation bar.

This search-enabled navigation bar is functionally equivalent to the standard CupertinoSliverNavigationBar constructor, but with the addition of searchField, which sits at the bottom of the navigation bar.

When the search field is tapped, leading, trailing, middle, and largeTitle all collapse, causing the search field to animate to the 'top' of the navigation bar. A 'Cancel' button is presented next to the active searchField, which when tapped, closes the search view, bringing the navigation bar back to its initial state.

If automaticallyImplyTitle is false, then the largeTitle argument is required.

This example demonstrates how to use a CupertinoSliverNavigationBar.search to manage a search view.
link

To create a local project with this code sample, run:
flutter create --sample=cupertino.CupertinoSliverNavigationBar.CupertinoSliverNavigationBar.search.1 mysample

Implementation

const CupertinoSliverNavigationBar.search({
  super.key,
  required Widget this.searchField,
  this.largeTitle,
  this.leading,
  this.automaticallyImplyLeading = true,
  this.automaticallyImplyTitle = true,
  this.alwaysShowMiddle = true,
  this.previousPageTitle,
  this.middle,
  this.trailing,
  this.border = _kDefaultNavBarBorder,
  this.backgroundColor,
  this.automaticBackgroundVisibility = true,
  this.enableBackgroundFilterBlur = true,
  this.brightness,
  this.padding,
  this.transitionBetweenRoutes = true,
  this.heroTag = _defaultHeroTag,
  this.stretch = false,
  this.bottomMode = NavigationBarBottomMode.automatic,
  this.onSearchableBottomTap,
}) : assert(
       automaticallyImplyTitle || largeTitle != null,
       'No largeTitle has been provided but automaticallyImplyTitle is also '
       'false. Either provide a largeTitle or set automaticallyImplyTitle to '
       'true.',
     ),
     bottom = null,
     _searchable = true;