SearchDropDownController<T> class
Controller for SearchDropDown that manages the list data, selection, and search text.
Constructors
-
SearchDropDownController({SearchController? searchController, required List<
ValueItem< listItems, bool addMode = true, ValueItem<T> >T> newValueItem(String input)?, dynamic onAddItem(ValueItem<T> )?, bool editMode = false, dynamic onEditItem(ValueItem<T> originalItem, ValueItem<T> newValue)?, DialogSettings? editDialogSettings, bool deleteMode = true, dynamic onDeleteItem(ValueItem<T> )?, bool confirmDelete = false, DialogSettings? deleteDialogSettings, void updateSelectedItem(ValueItem<T> ?)?, bool verifyInputItem(ValueItem<T> )?, DialogSettings? verifyDialogSettings, bool showClearIcon = false, ValueItem<T> ? initialSelectedItem, int sortType = 0, bool enabled = true, void onFilterUpdated()?, bool latinize = true, bool caseSensitive = false, bool trim = true})
Properties
- addMode → bool
-
Allow the user to add new items to the list.
final
- caseSensitive → bool
-
final
- clearVisible ↔ bool
-
Whether the clear button should be visible (true if there's a selection/text and showClearIcon is true).
getter/setter pair
- confirmDelete → bool
-
Whether to require confirmation from the user before deleting an item.
final
- deleteDialogSettings → DialogSettings?
-
Settings for the delete confirmation dialog.
final
- deleteMode → bool
-
Allow the user to delete items from the list.
final
- editDialogSettings → DialogSettings?
-
Settings for the edit dialog (appearance, text, etc.).
final
- editMode → bool
-
Allow the user to edit existing items in the list.
final
- enabled ↔ bool
-
Whether the dropdown is enabled for user interaction.
getter/setter pair
-
filteredItems
→ UnmodifiableListView<
ValueItem< T> > -
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- highlightedIndex → int
-
no setter
- latinize → bool
-
final
-
listItems
→ List<
ValueItem< T> > -
List of all items to be presented in the dropdown.
final
- localSearchController → SearchController
-
The internal search controller for the SearchAnchor/SearchBar.
final
-
newValueItem
→ ValueItem<
T> Function(String input)? -
Function to create a new
ValueItem<T>from user input (required if addMode is true).final -
onAddItem
→ dynamic Function(ValueItem<
T> )? -
Function to be executed after a new item is added to the list.
final
-
onDeleteItem
→ dynamic Function(ValueItem<
T> )? -
Function to be executed after an item is deleted.
final
-
onEditItem
→ dynamic Function(ValueItem<
T> originalItem, ValueItem<T> newValue)? -
Function to be executed after an item is edited. Provides the original item and the new item.
final
- onFilterUpdated → void Function()?
-
Optional callback triggered when filteredItems is updated.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
selectedItem
↔ ValueItem<
T> ? -
The currently selected item (if any).
getter/setter pair
- showClearIcon → bool
-
Whether to show the clear ("X") icon when there is text or a selected value.
This should typically match the
searchBarSettings.showClearIconin the widget.final - trim → bool
-
final
-
updateSelectedItem
→ void Function(ValueItem<
T> ?)? -
Callback to update the selected item in external state (called whenever an item is selected or cleared).
final
- verifyDialogSettings → DialogSettings?
-
Settings for the "invalid input" dialog shown when verifyInputItem fails.
final
-
verifyInputItem
→ bool Function(ValueItem<
T> )? -
Function to check if a newly added item is valid. Returns
falseto reject the input.final
Methods
-
addItem(
String text, BuildContext context) → Future< void> - Handles adding a new item to the list from the given input text. Returns a Future that completes after the operation (and any dialog) is handled.
-
clearSelection(
) → void - Clears the current selection and search field text without notifying external callbacks.
-
clearSelectionAndNotify(
) → void - Clears the current selection and search field text, and notifies external callbacks.
-
deleteItem(
ValueItem< T> item, BuildContext context) → Future<void> - Handles deleting an item from the list. Shows a confirmation dialog if required.
-
dispose(
) → void - Disposes the internal SearchController. Call this if the controller is no longer needed.
-
editItem(
ValueItem< T> item, BuildContext context) → Future<void> - Handles editing (modifying) an existing item in the list. Opens an edit dialog and updates the item via the provided callback if confirmed.
-
filterList(
String text) → void -
Filters the list based on the provided
text. Normalizes accents and case. -
forceSelection(
String label) → void - Forces the selection of an item by its label, if it exists in the list.
-
handleEnterKey(
) → void - Default ENTER behavior when there is no keyboard highlight: selects the first item in the filtered list (if any).
-
highlightNext(
) → void - Move highlight to the next item (Arrow Down).
-
highlightPrevious(
) → void - Move highlight to the previous item (Arrow Up).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onSearchClose(
bool clearOnClose) → void -
onSearchOpen(
) → void - Prepares the controller state when the search view is opened. (Resets the filtered list to show all items and enables filtering.)
-
resetHighlight(
) → void - Reset highlight whenever the filtered list changes.
-
resetSelection(
{bool highlight = false}) → void - Resets the selection to its default state (clears the current selection and text).
-
selectHighlighted(
) → void - Select the item currently highlighted.
-
selectItem(
ValueItem< T> item) → void - Selects the given item from the list. Updates the search text and notifies listeners.
-
sortList(
int sortType) → void - Sorts the listItems based on the given sort type.
-
toggleEnabled(
) → void - Toggles the enabled/disabled state of the dropdown.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateListItems(
List< ValueItem< newList, bool shouldReset) → voidT> > - Substitutes the current listItems with a new list, rebuilding internal caches and updating the filtered list. This should be called when the source list items are changed externally. If selectedItem isn't null, shouldReset parameter will be bypassed.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited