FossAutocomplete class Inputs

See the combobox documentation ↗ or try it live in the playground ↗.
A text field whose dropdown filters a list of suggestions as you type.
The value is the field string, reported through onChanged; picking a suggestion writes its text into the field. The items are hints, not a constraint, so the field accepts any typed value. There is no selection indicator and no multiple selection: for those, use FossCombobox.
Colors, type, and metrics come from context.fossTheme; pass a
FossComboboxStyle to style for a one-off.
Customize globally by passing your own FossThemeData, or per instance
through the widget's style object. There are no per-instance token props:
to change color, radius, or spacing, change the theme.
See also FossSelect for selection without typing.
FossAutocomplete(
label: 'Fruit',
hintText: 'Type to filter',
items: const ['Apple', 'Banana', 'Cherry'],
onChanged: (value) => setState(() => fruit = value),
);
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- FossAutocomplete
Constructors
-
FossAutocomplete({required List<
String> items, TextEditingController? controller, FocusNode? focusNode, FossTextFieldSize size = FossTextFieldSize.md, String? label, String? hintText, String? errorText, bool enabled = true, bool showTrigger = false, bool showClear = false, Widget? startAddon, bool filter(String label, String query)?, ValueChanged<String> ? onChanged, String emptyText = _defaultEmptyText, FossComboboxStyle? style, Key? key}) -
const
Properties
- controller → TextEditingController?
-
Holds the editable text. Created and disposed internally when null.
final
- emptyText → String
-
Caption shown when the query matches no suggestion.
final
- enabled → bool
-
Whether the field accepts input. Disabled when false.
final
- errorText → String?
-
When non-null, marks the field invalid and recolors its border.
final
- filter → bool Function(String label, String query)?
-
Overrides the default case-insensitive substring match. Receives the
option label and the current query.
final
- focusNode → FocusNode?
-
Manages keyboard focus. Created and disposed internally when null.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String?
-
Placeholder shown while the field is empty.
final
-
items
→ List<
String> -
The suggestions to filter as the user types.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- label → String?
-
Optional label rendered above the field.
final
-
onChanged
→ ValueChanged<
String> ? -
Called whenever the field text changes, including on a pick.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showClear → bool
-
Whether to show a trailing clear button while the field is non-empty.
final
- showTrigger → bool
-
Whether to show the trailing chevron that opens the list. Hidden by
default; the list also opens on focus and typing.
final
- size → FossTextFieldSize
-
The field height and type scale.
final
- startAddon → Widget?
-
Optional leading widget, typically a search glyph. Icon-agnostic.
final
- style → FossComboboxStyle?
-
Per-instance overrides layered on the theme-resolved style.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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