Autocomplete<T> class
A controlled text field with an attached suggestion presentation.
The caller owns controller, options, and status. This widget owns only terminal interaction and presentation: it never fetches, filters, debounces, or suppresses stale asynchronous results.
Tab follows ordinary focus traversal from the field into a ready option list. List navigation moves the highlight; Enter in either the field or list and a primary click select through onSelected. Escape invokes onDismiss only while a presentation is visible. Selection and dismissal restore field focus when that node remains live and requestable.
Omitted focus nodes are created and disposed by this widget. Supplied nodes and the required text controller are borrowed and never disposed.
- Inheritance
-
- Object
- Widget
- StatefulWidget
- Autocomplete
Constructors
-
Autocomplete({required TextEditingController controller, required List<
T> options, required AutocompleteStatus status, required AutocompleteOptionBuilder<T> optionBuilder, required ValueChanged<String> onChanged, required ValueChanged<T> onSelected, required VoidCallback onDismiss, Key? key, FocusNode? focusNode, FocusNode? optionsFocusNode, String? placeholder, bool autofocus = false, int maxOptionsHeight = 5, bool showScrollIndicator = false, WidgetBuilder? loadingBuilder, WidgetBuilder? emptyBuilder, WidgetBuilder? errorBuilder, Color? inputBackgroundColor, Color? optionsBackgroundColor, Color? selectedBackgroundColor}) -
Creates a controlled autocomplete field and attached presentation.
const
Properties
- autofocus → bool
-
Whether the field requests focus when first mounted.
final
- controller → TextEditingController
-
Borrowed owner of the field's text and selection.
final
- emptyBuilder → WidgetBuilder?
-
Replaces the default one-row
No options.presentation.final - errorBuilder → WidgetBuilder?
-
Replaces the default one-row
Options unavailable.presentation.final - focusNode → FocusNode?
-
Borrowed field focus node, or null for an internally owned node.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- inputBackgroundColor → Color?
-
Fill passed to the internal text field.
final
- key → Key?
-
Controls how this widget replaces another of the same type.
finalinherited
- loadingBuilder → WidgetBuilder?
-
Replaces the default one-row
Loading…presentation.final - maxOptionsHeight → int
-
Maximum number of ready option rows painted at once. Must be at least 1.
final
-
onChanged
→ ValueChanged<
String> -
Receives every edit made by the internal text field.
final
- onDismiss → VoidCallback
-
Must update controlled state to hide the presentation after Escape.
final
-
onSelected
→ ValueChanged<
T> -
Receives the option chosen by Enter or a primary click.
final
-
optionBuilder
→ AutocompleteOptionBuilder<
T> -
Builds one visible option row.
final
-
options
→ List<
T> -
Controlled options displayed when status is AutocompleteStatus.ready.
final
- optionsBackgroundColor → Color?
-
Fill behind every attached status or option surface.
final
- optionsFocusNode → FocusNode?
-
Borrowed suggestion-list focus node, or null for an internally owned node.
final
- placeholder → String?
-
Hint painted by the text field while its value is empty.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedBackgroundColor → Color?
-
Fill behind the highlighted option while its list has focus.
final
- showScrollIndicator → bool
-
Whether the ready list reserves a scroll-indicator gutter.
final
- status → AutocompleteStatus
-
Controlled presentation shown below the field.
final
Methods
-
createState(
) → State< Autocomplete< T> > -
Creates the mutable State for this widget.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited