AutoComplete class

A text field that offers to finish what is being typed: a city, an e-mail domain, a name from a long list.

AutoComplete(
  placeholder: 'City',
  options: const [
    AutoCompleteOption(value: 'Amsterdam'),
    AutoCompleteOption(value: 'Ankara'),
    AutoCompleteOption(value: 'Athens'),
  ],
  onSelect: (city) => setState(() => this.city = city),
)

Unlike a Select, what is typed is the value: a suggestion only fills it in. The suggestions open under the field as it is typed in, narrowed to those that hold the text; the arrow keys walk them, Enter takes one and Escape puts them away.

Inheritance

Constructors

AutoComplete({Key? key, required List<AutoCompleteOption> options, String? value, String? defaultValue, ValueChanged<String>? onChanged, ValueChanged<String>? onSelect, ValueChanged<String>? onSearch, bool filterOption(String input, AutoCompleteOption option)?, String? placeholder, bool? allowClear, bool? disabled, InputStatus? status, ControlSize? size, Widget? notFoundContent, bool backfill = false, bool defaultActiveFirstOption = true, double listHeight = 256, bool autofocus = false, FocusNode? focusNode, String? semanticsLabel, AutoCompleteToken? token})
Creates an AutoComplete.
const

Properties

allowClear → bool?
Whether a cross clears the field.
final
autofocus → bool
Whether the field takes the focus as it appears.
final
backfill → bool
Whether the suggestion the arrow keys reach is written into the field as they reach it, before Enter takes it.
final
defaultActiveFirstOption → bool
Whether the first suggestion is already reached when they open, so Enter takes it without an arrow first. Defaults to yes.
final
defaultValue → String?
The text the field starts with, when value is null.
final
disabled → bool?
Greys the field out.
final
filterOption → bool Function(String input, AutoCompleteOption option)?
Whether a suggestion is offered for what was typed. Null keeps those whose value holds the text, whatever its case.
final
focusNode → FocusNode?
The field's focus, for moving it from outside.
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
listHeight → double
The most the suggestions may stand tall before they scroll.
final
notFoundContent → Widget?
Shown under the field when nothing matches. Null shows nothing — the suggestions simply do not open.
final
onChanged → ValueChanged<String>?
Called with the text whenever it changes, typed or filled in.
final
onSearch → ValueChanged<String>?
Called with the text as it is typed — not when a suggestion fills it in — for fetching suggestions to match.
final
onSelect → ValueChanged<String>?
Called with a suggestion's value when it is chosen.
final
options → List<AutoCompleteOption>
The suggestions. For suggestions fetched as the reader types, hand over what came back for onSearch and pass a filterOption that keeps everything.
final
placeholder → String?
Shown in the empty field.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticsLabel → String?
What a screen reader calls the field.
final
size → ControlSize?
How tall the field is, as an Input.
final
status → InputStatus?
Colours the field's border as a warning or an error.
final
token → AutoCompleteToken?
Per-instance token overrides.
final
value → String?
The text, held from outside. Null lets the field keep its own, starting from defaultValue.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<AutoComplete>
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, int wrapWidth = 65}) → 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