SearchButton constructor

const SearchButton({
  1. Key? key,
  2. ValueChanged<String?>? onSearch,
  3. SearchButtonMode mode = SearchButtonMode.transactional,
})

Constructs a SearchButton with customizable search behavior.

The mode determines query handling: live mode calls onSearch on every change (including empty or null states), while transactional mode only invokes it for non-empty submissions and closes the box. The onSearch callback receives the trimmed query string or null (live mode only), enabling integration with data sources like filtered Collections or navigation triggers.

Usage example:

SearchButton(
  mode: SearchButtonMode.live,
  onSearch: (query) {
    if (query == null) {
      // Clear filters in a [Selector] or [Collection]
    } else {
      // Apply live search to update UI
    }
  },
)

Embed in an AppBar or toolbar for discoverability, often alongside Fab or IconButton for related actions.

Implementation

const SearchButton(
    {super.key, this.onSearch, this.mode = SearchButtonMode.transactional});