CNToolbar.search constructor

const CNToolbar.search({
  1. Key? key,
  2. List<CNToolbarAction>? leading,
  3. List<CNToolbarAction>? middle,
  4. List<CNToolbarAction>? trailing,
  5. required CNSearchConfig? searchConfig,
  6. CNSymbol? contextIcon,
  7. CNToolbarMiddleAlignment middleAlignment = CNToolbarMiddleAlignment.center,
  8. bool transparent = false,
  9. Color? tint,
  10. double? height,
  11. double? pillHeight,
})

Creates a toolbar with integrated search functionality.

When the search icon is tapped, the toolbar animates to show a search bar with optional context indicator. Search button is automatically added to trailing actions.

Example:

CNToolbar.search(
  leading: [CNToolbarAction(icon: CNSymbol('star.fill'), onPressed: () {})],
  searchConfig: CNSearchConfig(
    placeholder: 'Search',
    onSearchTextChanged: (text) => print(text),
    resultsBuilder: (context, text) => SearchResults(text),
  ),
  contextIcon: CNSymbol('apps.iphone'),
)

Implementation

const CNToolbar.search({
  super.key,
  this.leading,
  this.middle,
  this.trailing,
  required this.searchConfig,
  this.contextIcon,
  this.middleAlignment = CNToolbarMiddleAlignment.center,
  this.transparent = false,
  this.tint,
  this.height,
  this.pillHeight,
}) : _isSearchEnabled = true;