SearchDelegate<T> class

Delegate for showSearch to define the content of the search page.

The search page always shows an AppBar at the top where users can enter their search queries. The buttons shown before and after the search query text field can be customized via SearchDelegate.leading and SearchDelegate.actions.

The body below the AppBar can either show suggested queries (returned by SearchDelegate.buildSuggestions) or - once the user submits a search - the results of the search as returned by SearchDelegate.buildResults.

SearchDelegate.query always contains the current query entered by the user and should be used to build the suggestions and results.

The results can be brought on screen by calling SearchDelegate.showResults and you can go back to showing the suggestions by calling SearchDelegate.showSuggestions.

Once the user has selected a search result, SearchDelegate.close should be called to remove the search page from the top of the navigation stack and to notify the caller of showSearch about the selected search result.

A given SearchDelegate can only be associated with one active showSearch call. Call SearchDelegate.close before re-using the same delegate instance for another showSearch call.

Constructors

SearchDelegate()

Properties

query String
The current query string shown in the Appbar. [...]
read / write
transitionAnimation Animation<double>
Animation triggered when the search pages fades in or out. [...]
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

appBarTheme(BuildContext context) ThemeData
The theme used to style the AppBar. [...]
buildActions(BuildContext context) List<Widget>
Widgets to display after the search query in the AppBar. [...]
buildLeading(BuildContext context) Widget
A widget to display before the current query in the AppBar. [...]
buildResults(BuildContext context) Widget
The results shown after the user submits a search from the search page. [...]
buildSuggestions(BuildContext context) Widget
Suggestions shown in the body of the search page while the user types a query into the search field. [...]
close(BuildContext context, T result) → void
Closes the search page and returns to the underlying route. [...]
showResults(BuildContext context) → void
Transition from the suggestions returned by buildSuggestions to the query results returned by buildResults. [...]
showSuggestions(BuildContext context) → void
Transition from showing the results returned by buildResults to showing the suggestions returned by buildSuggestions. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
@pragma('vm:entry-point'), inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited