SearchBar class
Search field widget being displayed within Scaffold element. Depending on its state and passed attributes it can be rendered as an appBar action, expanded to its full size when activated or merged with appBar, making the search field visible although not activated.
SearchBar needs to be placed underneath Scaffold element in the widget tree, in place of the original AppBar.
Specifying onQueryChanged, onQuerySubmitted allows to receive callbacks whenever user input occurs. If loader argument is passed, data set will be automatically loaded when query changes (or is submitted). When it happens, widget will change its preferred size requested by Scaffold ancestor, making the ListView take whole available space below app bar. Once user cancels search action (navigates back) widget is rebuilt with default app bar size making Scaffold body visible again.
Constructors
-
SearchBar({@required AppBar defaultBar, ValueChanged<
String> onQueryChanged, ValueChanged<String> onQuerySubmitted, QuerySetLoader loader, SystemUiOverlayStyle overlayStyle, String searchHint: 'Tap to search...', bool iconified: true, bool autofocus, SearchItem searchItem, void onActivatedChanged, SearchBarAttrs attrs })
Properties
-
activatedChangedCallback
→ ValueChanged<
bool> -
Callback function receiving widget's current state whenever user begins
or cancels/ends search action.
final
- attrs → SearchBarAttrs
-
SearchBarAttrs instance allowing to specify part of exact values used
during widget building.
final
- autofocus → bool
-
Determining if search field should get focus once it becomes visible.
final
- defaultBar → AppBar
-
AppBar widget that will be displayed whenever SearchBar is not in
activated state.
final
- iconified → bool
-
Indicating way of representing non-activated SearchBar:
true if widget should be showed as an action item in defaultAppBar,
false if widget should be merged with defaultAppBar.
final
- loader → QuerySetLoader
-
Widget automatically loading data corresponding to current query
and displaying it in ListView.
final
-
onQueryChanged
→ ValueChanged<
String> -
Function being called whenever query changes with its current value
as an argument.
final
-
onQuerySubmitted
→ ValueChanged<
String> -
Function being called whenever query is submitted with its current value
as an argument.
final
- overlayStyle → SystemUiOverlayStyle
-
Status bar overlay brightness applied when widget is activated.
final
- preferredSize → Size
-
The size this widget would prefer if it were otherwise unconstrained. [...]
read-only
- searchHint → String
-
Hint string being displayed until user inputs any text.
final
- searchItem → SearchItem
-
Defining how to position and build search item widget in AppBar.
final
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- key → Key
-
Controls how one widget replaces another widget in the tree. [...]
final, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
createState(
) → State< StatefulWidget> - Creates the mutable state for this widget at a given location in the tree. [...]
-
createElement(
) → StatefulElement -
Creates a
StatefulElement
to manage this widget's location in the tree. [...]inherited -
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children. [...]@protected, inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node. [...]
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
@pragma("vm:entry-point"), inherited
-
toDiagnosticsNode(
{String name, DiagnosticsTreeStyle style }) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by toStringDeep. [...]
inherited
-
toString(
{DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne: '', String prefixOtherLines, DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a string representation of this node and its descendants. [...]
inherited
-
toStringShallow(
{String joiner: ', ', DiagnosticLevel minLevel: DiagnosticLevel.debug }) → String -
Returns a one-line detailed description of the object. [...]
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited