AutoComplete constructor

const AutoComplete({
  1. Key? key,
  2. required List<String> suggestions,
  3. required Widget child,
  4. BoxConstraints? popoverConstraints,
  5. PopoverConstraint? popoverWidthConstraint,
  6. AlignmentDirectional? popoverAnchorAlignment,
  7. AlignmentDirectional? popoverAlignment,
  8. AutoCompleteMode? mode,
  9. AutoCompleteCompleter completer = _defaultCompleter,
})

Creates an AutoComplete widget.

Wraps the provided child with autocomplete functionality using the given suggestions list. The popover appearance and behavior can be customized through the optional positioning and constraint parameters.

Parameters:

  • suggestions (List
  • child (Widget, required): widget to receive autocomplete functionality
  • popoverConstraints (BoxConstraints?, optional): popover size limits
  • popoverWidthConstraint (PopoverConstraint?, optional): width strategy
  • popoverAnchorAlignment (AlignmentDirectional?, optional): anchor point
  • popoverAlignment (AlignmentDirectional?, optional): popover align point
  • mode (AutoCompleteMode?, optional): text replacement strategy
  • completer (AutoCompleteCompleter, default: identity): suggestion processor

Example:

AutoComplete(
  suggestions: suggestions,
  mode: AutoCompleteMode.append,
  completer: (text) => '$text ',
  child: TextField(),
)

Implementation

const AutoComplete({
  super.key,
  required this.suggestions,
  required this.child,
  this.popoverConstraints,
  this.popoverWidthConstraint,
  this.popoverAnchorAlignment,
  this.popoverAlignment,
  this.mode,
  this.completer = _defaultCompleter,
});