CNNavigationBar.search constructor

const CNNavigationBar.search({
  1. Key? key,
  2. List<CNNavigationBarAction>? leading,
  3. String? title,
  4. double? titleSize,
  5. VoidCallback? onTitlePressed,
  6. List<CNNavigationBarAction>? trailing,
  7. required CNSearchConfig? searchConfig,
  8. bool largeTitle = false,
  9. bool transparent = true,
  10. Color? tint,
  11. double? height,
  12. List<String>? segmentedControlLabels,
  13. int? segmentedControlSelectedIndex,
  14. ValueChanged<int>? onSegmentedControlValueChanged,
  15. double? segmentedControlHeight,
  16. double? segmentedControlLabelSize,
  17. 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;