AutocompleteLabel<T> class Null safety

A widget that helps the user to select a label by entering some text and selecting from a list of options.

The autocomplete label calls the onChanged callback whenever the user changes the values in the field.

To control the values that is displayed in the autocomplete label, use the autocompleteLabelController. For example, to set the initial values of the autocomplete label, use a controller that already contains some values. The controller can also control the selectable label options source (and to observe changes to the values).

Reading values:

A common way to read a values from a AutocompleteLabel is to use the onChanged callback. This callback is applied to the autocomplete label's current values when the user finishes editing or selected option.

For most applications the onChanged callback will be sufficient for reacting to user input.

Keep in mind you can also always read the current string from a AutocompleteLabel's AutocompleteLabelController using AutocompleteLabelController.text.



AutocompleteLabel({Key? key, ValueViewBuilder valueViewBuilder = defaultValueViewBuilder, ValueBoxBuilder valueBoxBuilder = defaultValueBoxBuilder, OptionViewBuilder optionViewBuilder = defaultOptionViewBuilder, OptionBoxBuilder optionBoxBuilder = defaultOptionBoxBuild, FieldViewBuilder fieldViewBuilder = defaultFieldViewBuilder, AutocompleteLabelController? autocompleteLabelController, TextEditingController? textEditingController, OptionsBuilder? optionsBuilder, ValueBuilder valueBuilder = defaultValueBuilder, FocusNode? focusNode, OnChanged? onChanged, double minOptionBoxHeight = 100, bool keepAutofocus = true, OptionToString displayStringForOption = defaultStringForOption, VerticalDirection? optionBoxDirection})
Creates an instance of AutocompleteLabel.


autocompleteLabelController AutocompleteLabelController
Controls the values being edited.
displayStringForOption OptionToString
Returns the string to display in the field when the label option is selected. This is useful when using a custom T type and the string to display is different than the string to search by.
fieldViewBuilder FieldViewBuilder
Builds the field whose input is used to get the options.
focusNode FocusNode
Defines the keyboard focus for this widget.
hashCode int
The hash code for this object.
keepAutofocus bool
Whether to keep the focus automatically, this autofocus is not TextField.autofocus.
key Key?
Controls how one widget replaces another widget in the tree.
minOptionBoxHeight double
The minimum height of the selectable label options widgets.
onChanged OnChanged?
Called when the user initiates a change to the AutocompleteLabel's values: when they have inserted or deleted value.
optionBoxBuilder OptionBoxBuilder
Builds the selectable label options widgets(which is option box) from a list of values objects.
optionBoxDirection VerticalDirection?
The vertical direction attribute of the selectable label options widgets.
optionsBuilder OptionsBuilder?
A function that returns the current selectable label option objects given the current string.
optionViewBuilder OptionViewBuilder
Build a single item widget of the selectable label options widgets from the option of the specified index.
runtimeType Type
A representation of the runtime type of the object.
textEditingController TextEditingController
Controls the text being edited.
valueBoxBuilder ValueBoxBuilder
Builds the deletable label values widgets(which is value box) from textField and a list of values objects.
valueBuilder ValueBuilder
A function that returns the label object given the current string.
valueViewBuilder ValueViewBuilder
Build a single item widget of the deletable label values widgets from the value of the specified index


createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
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.

Static Methods

defaultFieldViewBuilder(BuildContext context, TextEditingController textEditingController, FocusNode focusNode, VoidCallback onFieldSubmitted) Widget
The default way to build the text field widget in fieldViewBuilder.
defaultOptionBoxBuild(BuildContext context, OnSelected<Object> onSelected, OptionViewBuilder optionViewBuilder, Iterable options, int highlightIndex, AxisDirection boxDirection) Widget
The default way to build the selectable label options widgets in optionBoxBuilder.
defaultOptionViewBuilder(BuildContext context, OnSelected<Object> onSelected, int index, dynamic option, bool isHighlight) Widget
The default way to build the single item of the option box in optionViewBuilder.
defaultStringForOption(dynamic option) String
The default way to convert an option to a string in displayStringForOption.
defaultValueBoxBuilder(BuildContext context, ValueOnDeleted onDeleted, ValueViewBuilder valueViewBuilder, Widget textField, Iterable values) Widget
The default way to build the deletable label values widgets in valueBoxBuilder.
defaultValueBuilder(String value) → dynamic
The default way to convert an string to a label value in valueBuilder.
defaultValueViewBuilder(BuildContext context, ValueOnDeleted onDeleted, int index, dynamic value) Widget
The default way to build the single item of the value box in valueViewBuilder.