onSuggestionSelected property

SuggestionSelectionCallback<T>? onSuggestionSelected
final

Called when a suggestion is tapped.

This callback must not be null. It is called by the TypeAhead widget and provided with the value of the tapped suggestion.

For example, you might want to navigate to a specific view when the user tabs a suggestion:

onSuggestionSelected: (suggestion) {
  Navigator.of(context).push(MaterialPageRoute(
    builder: (context) => SearchResult(
      searchItem: suggestion
    )
  ));
}

Or to set the value of the text field:

onSuggestionSelected: (suggestion) {
  _controller.text = suggestion['name'];
}

Implementation

final SuggestionSelectionCallback<T>? onSuggestionSelected;