Autocomplete<T extends Object> class Null safety

A widget for helping the user make a selection by entering some text and choosing from among a list of options.

The user's text input is received in a field built with the fieldViewBuilder parameter. The options to be displayed are determined using optionsBuilder and rendered with optionsViewBuilder.

This example shows how to create a very basic Autocomplete widget using the default UI.
To create a local project with this code sample, run:
flutter create --sample=material.Autocomplete.1 mysample

This example shows how to create an Autocomplete widget with a custom type. Try searching with text from the name or email field.
To create a local project with this code sample, run:
flutter create --sample=material.Autocomplete.2 mysample

See also:

  • RawAutocomplete, which is what Autocomplete is built upon, and which contains more detailed examples.


Autocomplete({Key? key, required AutocompleteOptionsBuilder<T> optionsBuilder, AutocompleteOptionToString<T> displayStringForOption = RawAutocomplete.defaultStringForOption, AutocompleteFieldViewBuilder fieldViewBuilder = _defaultFieldViewBuilder, AutocompleteOnSelected<T>? onSelected, double optionsMaxHeight = 200.0, AutocompleteOptionsViewBuilder<T>? optionsViewBuilder, TextEditingValue? initialValue})
Creates an instance of Autocomplete.


displayStringForOption AutocompleteOptionToString<T>
Returns the string to display in the field when the option is selected. [...]
fieldViewBuilder AutocompleteFieldViewBuilder
Builds the field whose input is used to get the options. [...]
hashCode int
The hash code for this object. [...]
@nonVirtual, read-only, inherited
initialValue TextEditingValue?
The initial value to use for the text field.
key Key?
Controls how one widget replaces another widget in the tree. [...]
final, inherited
onSelected AutocompleteOnSelected<T>?
Called when an option is selected by the user. [...]
optionsBuilder AutocompleteOptionsBuilder<T>
A function that returns the current selectable options objects given the current TextEditingValue.
optionsMaxHeight double
The maximum height used for the default Material options list widget. [...]
optionsViewBuilder AutocompleteOptionsViewBuilder<T>?
Builds the selectable options widgets from a list of options objects. [...]
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


build(BuildContext context) Widget
Describes the part of the user interface represented by this widget. [...]
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree. [...]
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. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep. [...]
toString({DiagnosticLevel minLevel =}) String
A string representation of this object. [...]
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants. [...]
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object. [...]
toStringShort() String
A short, textual description of this widget.


operator ==(Object other) bool
The equality operator. [...]
@nonVirtual, inherited