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.

Inheritance

Constructors

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.

Properties

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

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
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.
@protectedinherited
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.
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.
@nonVirtualinherited

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.