SearchAutocomplete<T> class
A SearchAutocomplete widget to provide an auto-complete search functionality with a dropdown.
This widget allows for extensive customization of the search field, dropdown items, and contains hooks for search logic.
Constructor Parameters:
options: A list of generic type options that will populate the dropdown.initValue: The initial value that will appear in the search bar.getString: A function that takes an item of generic typeTand returns itsStringrepresentation.onSearch: A function that handles search logic and is invoked when the user types in the search bar.fieldBuilder: A custom builder function for the search bar. If not provided, a default one is used.dropDownBuilder: A custom builder function for the dropdown items. If not provided, a default one is used.onSelected: A function that fires when an item is selected from the dropdown.hintText: A placeholder text that appears in the search bar.emptyDropDown: A custom builder function that builds a widget to display when the dropdown is empty.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SearchAutocomplete
Constructors
-
SearchAutocomplete({Key? key, required List<
T> options, required T? initValue, required String getString(T), required ValueSetter<String> onSearch, TextFieldWithArgs? fieldBuilder, DropDownWithArgs<T> ? dropDownBuilder, ValueChanged<T> ? onSelected, String? hintText, Widget emptyDropDown(TextEditingController controller, VoidCallback close)?}) -
Creates a
SearchAutocompletewidget.const
Properties
-
dropDownBuilder
→ DropDownWithArgs<
T> ? -
A builder function to create custom dropdown items.
final
- emptyDropDown → Widget Function(TextEditingController controller, VoidCallback close)?
-
A function to build a custom widget to display when the dropdown is empty.
final
- fieldBuilder → TextFieldWithArgs?
-
A builder function to create a custom search field.
final
- getString → String Function(T)
-
Function to transform an option object to its string representation.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String?
-
An optional placeholder text for the search field.
final
- initValue → T?
-
An optional initial value for the search field.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onSearch
→ ValueSetter<
String> -
Function that handles the search logic.
final
-
onSelected
→ ValueChanged<
T> ? -
Callback function that fires when an item is selected from the dropdown.
final
-
options
→ List<
T> -
A list of options to be displayed in the dropdown.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SearchAutocomplete< 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