SimpleAutocompleteFormField<T> class
Wraps a TextFormField and shows a list of suggestions below it.
As the user types, a list of suggestions is shown using onSearch and itemBuilder. The default suggestions container has a fills the available height but can be overridden by using suggestionsHeight or by using a custom suggestionsBuilder.
It is recommended to provide an itemFromString argument so that a suggestion can be selected if the user types in the value instead of tapping on it.
It is also recommended that the Widget tree containing a SimpleAutocompleteFormField include a ListView or other scrolling container such as a SingleChildScrollView. This prevents the suggestions from overflowing other UI elements like the keyboard.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FormField<
T> - SimpleAutocompleteFormField
Constructors
-
SimpleAutocompleteFormField({Key? key, int minSearchLength = 0, int maxSuggestions = 3, required Widget itemBuilder(BuildContext context, T? item), required Future<
List< onSearch(String search), SuggestionsBuilder? suggestionsBuilder, double? suggestionsHeight, ItemToString<T?> >T?> ? itemToString, ItemFromString<T?> ? itemFromString, ValueChanged<T?> ? onChanged, IconData? resetIcon = Icons.close, AutovalidateMode autovalidateMode = AutovalidateMode.disabled, FormFieldValidator<T?> ? validator, ValueChanged<T?> ? onFieldSubmitted, GestureTapCallback? onTap, FormFieldSetter<T?> ? onSaved, TextEditingController? controller, FocusNode? focusNode, T? initialValue, InputDecoration? decoration = const InputDecoration(), TextInputType? keyboardType = TextInputType.text, TextStyle? style, TextAlign textAlign = TextAlign.start, bool autofocus = false, bool obscureText = false, bool autocorrect = true, MaxLengthEnforcement maxLengthEnforcement = MaxLengthEnforcement.enforced, bool enabled = true, int? maxLines = 1, int? maxLength, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), TextCapitalization textCapitalization = TextCapitalization.none, List<TextInputFormatter> ? inputFormatters})
Properties
- autocorrect → bool
-
final
- autofocus → bool
-
final
- autovalidateMode → AutovalidateMode
-
Used to enable/disable this form field auto validation and update its
error text.
finalinherited
-
builder
→ FormFieldBuilder<
T> -
Function that returns the widget representing this form field. It is
passed the form field state as input, containing the current value and
validation state of this field.
finalinherited
- controller → TextEditingController?
-
final
- decoration → InputDecoration?
-
final
- enabled → bool
-
Whether the form is able to receive user input.
final
- focusNode → FocusNode?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialValue → T?
-
An optional value to initialize the form field to, or null otherwise.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
final
- itemBuilder → Widget Function(BuildContext context, T? item)
-
Represents an autocomplete suggestion.
final
-
itemFromString
→ ItemFromString<
T?> ? -
Called before
onChanged
when the input loses focus and a suggestion was not selected, for example if the user typed in an entire suggestion value without tapping on it. The default implementation simply returnsnull
.final -
itemToString
→ ItemToString<
T?> ? -
How the text field is filled in when an item is selected. If omitted, the
item's
toString()
method is used.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
final
- keyboardType → TextInputType?
-
final
- maxLength → int?
-
final
- maxLengthEnforcement → MaxLengthEnforcement
-
final
- maxLines → int?
-
final
- maxSuggestions → int
-
Maximum number of suggestions shown.
final
- minSearchLength → int
-
Minimum search length that shows suggestions.
final
- obscureText → bool
-
final
-
onChanged
→ ValueChanged<
T?> ? -
Called when an item is tapped or the field loses focus.
final
-
onFieldSubmitted
→ ValueChanged<
T?> ? -
final
-
onSaved
→ FormFieldSetter<
T?> ? -
An optional method to call with the final value when the form is saved via
FormState.save.
final
-
onSearch
→ Future<
List< Function(String search)T?> > -
Called to fill the autocomplete list's data.
final
- onTap → GestureTapCallback?
-
final
- resetIcon → IconData?
-
If not null, the TextField decoration's suffixIcon will be
overridden to reset the input using the icon defined here.
final
- restorationId → String?
-
Restoration ID to save and restore the state of the form field.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPadding → EdgeInsets
-
final
- style → TextStyle?
-
final
- suggestionsBuilder → SuggestionsBuilder
-
Container for the list of suggestions. Defaults to a scrollable
Column
that fills the available space.final - suggestionsHeight → double?
-
The height of the suggestions container. Has no effect if a custom
suggestionsBuilder is specified.
final
- textAlign → TextAlign
-
final
- textCapitalization → TextCapitalization
-
final
-
validator
→ FormFieldValidator<
T?> ? -
An optional method that validates an input. Returns an error string to
display if the input is invalid, or null otherwise.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _SimpleAutocompleteFormFieldState< T> -
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.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}) → 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