CNNavigationBar.search constructor
const
CNNavigationBar.search({
- Key? key,
- List<
CNNavigationBarAction> ? leading, - String? title,
- double? titleSize,
- VoidCallback? onTitlePressed,
- List<
CNNavigationBarAction> ? trailing, - required CNSearchConfig? searchConfig,
- bool largeTitle = false,
- bool transparent = true,
- Color? tint,
- double? height,
- List<
String> ? segmentedControlLabels, - int? segmentedControlSelectedIndex,
- ValueChanged<
int> ? onSegmentedControlValueChanged, - double? segmentedControlHeight,
- double? segmentedControlLabelSize,
- Color? segmentedControlTint,
Creates a navigation bar with integrated search functionality.
When the search icon is tapped, the navigation bar transforms to show a search bar. Search button is automatically added to trailing actions.
Example:
CNNavigationBar.search(
title: 'Contacts',
leading: [CNNavigationBarAction(icon: CNSymbol('plus'), onPressed: () {})],
searchConfig: CNSearchConfig(
placeholder: 'Search contacts',
onSearchTextChanged: (text) => print(text),
resultsBuilder: (context, text) => ContactResults(text),
),
)
Implementation
const CNNavigationBar.search({
super.key,
this.leading,
this.title,
this.titleSize,
this.onTitlePressed,
this.trailing,
required this.searchConfig,
this.largeTitle = false,
this.transparent = true,
this.tint,
this.height,
this.segmentedControlLabels,
this.segmentedControlSelectedIndex,
this.onSegmentedControlValueChanged,
this.segmentedControlHeight,
this.segmentedControlLabelSize,
this.segmentedControlTint,
}) : scrollableContent = null,
_isSearchEnabled = true,
_isScrollable = false;