SearchDelegate<T> class
abstract
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({String? searchFieldLabel, TextInputType? keyboardType, TextInputAction textInputAction = TextInputAction.search})
- Constructor to be called by subclasses which may specify searchFieldLabel, keyboardType and/or textInputAction.
Properties
- currentBody ↔ SearchBody?
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyboardType → TextInputType?
-
The type of action button to use for the keyboard.
final
- query ↔ String
-
The current query string shown in the AppBar.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchFieldLabel → String?
-
The hint text that is shown in the search field when it is empty.
final
- textInputAction → TextInputAction
-
The text input action configuring the soft keyboard to a particular action
button.
final
-
transitionAnimation
→ Animation<
double> -
Animation triggered when the search pages fades in or out.
no setter
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.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited