PerfectRawAutocomplete<T extends Object> class

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.

This is a core framework widget with very basic UI.

{@tool dartpad} This example shows how to create a very basic autocomplete widget using the fieldViewBuilder and optionsViewBuilder parameters.

** See code in examples/api/lib/widgets/autocomplete/raw_autocomplete.0.dart ** {@end-tool}

The type parameter T represents the type of the options. Most commonly this is a String, as in the example above. However, it's also possible to use another type with a toString method, or a custom displayStringForOption. Options will be compared using ==, so it may be beneficial to override Object.== and Object.hashCode for custom types.

{@tool dartpad} This example is similar to the previous example, but it uses a custom T data type instead of directly using String.

** See code in examples/api/lib/widgets/autocomplete/raw_autocomplete.1.dart ** {@end-tool}

{@tool dartpad} This example shows the use of RawAutocomplete in a form.

** See code in examples/api/lib/widgets/autocomplete/raw_autocomplete.2.dart ** {@end-tool}

See also:

  • Autocomplete, which is a Material-styled implementation that is based on RawAutocomplete.
Inheritance
Annotations

Constructors

PerfectRawAutocomplete({Key? key, required bool showOnTop, required PerfectAutocompleteOptionsViewBuilder<T> optionsViewBuilder, required PerfectAutocompleteOptionsBuilder<T> optionsBuilder, PerfectAutocompleteOptionToString<T> displayStringForOption = defaultStringForOption, PerfectAutocompleteFieldViewBuilder? fieldViewBuilder, PerfectAutocompleteOnSelected<T>? onSelected, PerfectTextController? textController})
Create an instance of RawAutocomplete.
const

Properties

displayStringForOption PerfectAutocompleteOptionToString<T>
Returns the string to display in the field when the option is selected.
final
fieldViewBuilder PerfectAutocompleteFieldViewBuilder?
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
optionsBuilder PerfectAutocompleteOptionsBuilder<T>
A function that returns the current selectable options objects given the current TextEditingValue.
final
optionsViewBuilder PerfectAutocompleteOptionsViewBuilder<T>
Builds the selectable options widgets from a list of options objects.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showOnTop bool
final
textController PerfectTextController?
The PerfectTextController that is used for the text field.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<PerfectRawAutocomplete<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, 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

Static Methods

defaultStringForOption(Object? option) String
The default way to convert an option to a string in displayStringForOption.
onFieldSubmitted<T extends Object>(GlobalKey<State<StatefulWidget>> key) → void
Calls PerfectAutocompleteFieldViewBuilder's onFieldSubmitted callback for the RawAutocomplete widget indicated by the given GlobalKey.