SearchBar class

A Material Design search bar.

Search bars include a leading Search icon, a text input field and optional trailing icons. A search bar is typically used to open a search view. It is the default trigger for a search view.

For TextDirection.ltr, the leading widget is on the left side of the bar. It should contain either a navigational action (such as a menu or up-arrow) or a non-functional search icon.

The trailing is an optional list that appears at the other end of the search bar. Typically only one or two action icons are included. These actions can represent additional modes of searching (like voice search), a separate high-level action (such as current location) or an overflow menu.

Inheritance

Constructors

Creates a Material Design search bar.
const

Properties

backgroundColor MaterialStateProperty<Color?>?
The search bar's background fill color.
final
constraints BoxConstraints?
Optional size constraints for the search bar.
final
controller TextEditingController?
Controls the text being edited in the search bar's text field.
final
elevation MaterialStateProperty<double?>?
The elevation of the search bar's Material.
final
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
hashCode int
The hash code for this object.
read-onlyinherited
hintStyle MaterialStateProperty<TextStyle?>?
The style to use for the hintText.
final
hintText String?
Text that suggests what sort of input the field accepts.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leading Widget?
A widget to display before the text input field.
final
onChanged ValueChanged<String>?
Invoked upon user input.
final
onTap GestureTapCallback?
Called when the user taps this search bar.
final
overlayColor MaterialStateProperty<Color?>?
The highlight color that's typically used to indicate that the search bar is focused, hovered, or pressed.
final
padding MaterialStateProperty<EdgeInsetsGeometry?>?
The padding between the search bar's boundary and its contents.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
shadowColor MaterialStateProperty<Color?>?
The shadow color of the search bar's Material.
final
shape MaterialStateProperty<OutlinedBorder?>?
The shape of the search bar's underlying Material.
final
side MaterialStateProperty<BorderSide?>?
The color and weight of the search bar's outline.
final
surfaceTintColor MaterialStateProperty<Color?>?
The surface tint color of the search bar's Material.
final
textStyle MaterialStateProperty<TextStyle?>?
The style to use for the text being edited.
final
trailing Iterable<Widget>?
A list of Widgets to display in a row after the text field.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SearchBar>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
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 ==(Object other) bool
The equality operator.
inherited