CNToolbar.search constructor
const
CNToolbar.search({
- Key? key,
- List<
CNToolbarAction> ? leading, - List<
CNToolbarAction> ? middle, - List<
CNToolbarAction> ? trailing, - required CNSearchConfig? searchConfig,
- CNSymbol? contextIcon,
- CNToolbarMiddleAlignment middleAlignment = CNToolbarMiddleAlignment.center,
- bool transparent = false,
- Color? tint,
- double? height,
- 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;