onCancelTap property

VoidCallback? onCancelTap
final

Called when the user taps the dismiss (×) cancel pill to close the keyboard.

Fires immediately after the library's own focus-release and onSearchToggle(false) calls, so the search state is already collapsing by the time your callback runs. Use this for:

  • Analytics (analytics.log('search_cancelled')).
  • Clearing search results so the body resets before the bar animates shut.
  • Programmatically unfocusing a custom FocusNode you own.

When null (the default), the standard dismiss behaviour runs unchanged.

Implementation

final VoidCallback? onCancelTap;