PerfectAutocomplete<T extends Object> class
A widget for helping the user make a selection by entering some text and choosing from among a list of options.
The user's text input is received in a field built with the
fieldViewBuilder parameter. The options to be displayed are determined
using optionsBuilder and rendered with optionsViewBuilder
.
{@tool dartpad} This example shows how to create a very basic Autocomplete widget using the default UI.
** See code in examples/api/lib/material/autocomplete/autocomplete.0.dart ** {@end-tool}
{@tool dartpad} This example shows how to create an Autocomplete widget with a custom type. Try searching with text from the name or email field.
** See code in examples/api/lib/material/autocomplete/autocomplete.1.dart ** {@end-tool}
{@tool dartpad} This example shows how to create an Autocomplete widget whose options are fetched over the network.
** See code in examples/api/lib/material/autocomplete/autocomplete.2.dart ** {@end-tool}
{@tool dartpad} This example shows how to create an Autocomplete widget whose options are fetched over the network. It uses debouncing to wait to perform the network request until after the user finishes typing.
** See code in examples/api/lib/material/autocomplete/autocomplete.3.dart ** {@end-tool}
{@tool dartpad} This example shows how to create an Autocomplete widget whose options are fetched over the network. It includes both debouncing and error handling, so that failed network requests show an error to the user and can be recovered from. Try toggling the network Switch widget to simulate going offline.
** See code in examples/api/lib/material/autocomplete/autocomplete.4.dart ** {@end-tool}
See also:
- RawAutocomplete, which is what Autocomplete is built upon, and which contains more detailed examples.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- PerfectAutocomplete
- Annotations
Constructors
-
PerfectAutocomplete({Key? key, PerfectTextController? textController, required PerfectAutocompleteOptionsBuilder<
T> optionsBuilder, AutocompleteOptionToString<T> displayStringForOption = RawAutocomplete.defaultStringForOption, Widget fieldViewBuilder(BuildContext context, PerfectTextController textController, VoidCallback onFieldSubmitted) = _defaultFieldViewBuilder, PerfectAutocompleteOnSelected<T> ? onSelected, double optionsWidth = 200.0, double optionsMaxHeight = 200.0, PerfectAutocompleteOptionBuilder<T> ? optionBuilder, bool showOnTop = false}) - Creates an instance of PerfectAutocomplete.
Properties
-
displayStringForOption
→ AutocompleteOptionToString<
T> -
Returns the string to display in the field when the option is selected.
final
- fieldViewBuilder → Widget Function(BuildContext context, PerfectTextController textController, VoidCallback onFieldSubmitted)
-
Builds the field whose input is used to get the options.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onSelected
→ PerfectAutocompleteOnSelected<
T> ? -
Called when an option is selected by the user.
final
-
optionBuilder
→ PerfectAutocompleteOptionBuilder<
T> ? -
Builds the selectable options widgets from a list of options objects.
final
-
optionsBuilder
→ PerfectAutocompleteOptionsBuilder<
T> -
A function that returns the current selectable options objects given the
current TextEditingValue.
final
- optionsMaxHeight → double
-
The maximum height used for the default Material options list widget.
final
- optionsWidth → double
-
The maximum height used for the default Material options list widget.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showOnTop → bool
-
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