SmartSearchMultiController<T> class

Controller for managing multi-selection search state.

This controller handles:

  • Multiple item selection from search results
  • Search query state management
  • Connection to pagination cubit for data fetching
  • Overlay visibility state
  • Keyboard navigation

Example:

final controller = SmartSearchMultiController<Product>(
  cubit: productsCubit,
  searchRequestBuilder: (query) => PaginationRequest(
    page: 1,
    pageSize: 20,
    searchQuery: query,
  ),
);
Inheritance

Constructors

SmartSearchMultiController({required SmartPaginationCubit<T> cubit, required PaginationRequest searchRequestBuilder(String query), SmartSearchConfig config = const SmartSearchConfig(), ValueChanged<List<T>>? onSelectionChanged, List<T>? initialSelectedValues, int? maxSelections})

Properties

config SmartSearchConfig
The current search configuration.
no setter
cubit SmartPaginationCubit<T>
The connected pagination cubit.
no setter
focusedIndex int
The index of the currently focused item (-1 if none).
no setter
focusedItem → T?
Returns the currently focused item, or null if none.
no setter
focusNode FocusNode
The focus node for the search field.
no setter
hasFocus bool
Whether the search field has focus.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasItemFocus bool
Whether an item is currently focused.
no setter
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
hasSelectedItems bool
Whether any items are selected.
no setter
hasText bool
Whether the search field has text.
no setter
isMaxSelectionsReached bool
Whether max selections has been reached.
no setter
isOverlayVisible bool
Whether the overlay is currently visible.
no setter
isSearching bool
Whether a search is currently in progress.
no setter
maxSelections int?
Maximum number of items that can be selected.
no setter
onSelectionChanged ValueChanged<List<T>>?
Sets the selection changed callback.
no getter
query String
The current search query text.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedItems List<T>
The list of currently selected items (unmodifiable).
no setter
selectionCount int
The number of selected items.
no setter
textController TextEditingController
The text editing controller for the search field.
no setter

Methods

addItem(T item) → void
Adds an item to the selection.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
clearAllSelections() → void
Clears all selected items.
clearItemFocus() → void
Clears the item focus.
clearSearch() → void
Clears the search text.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
handleKeyEvent(KeyEvent event) bool
Handles keyboard events for navigation.
hideOverlay() → void
Hides the search overlay.
isItemSelected(T item) bool
Checks if an item is selected.
moveToFirstItem() → void
Moves focus to the first item.
moveToLastItem() → void
Moves focus to the last item.
moveToNextItem() bool
Moves focus to the next item.
moveToPreviousItem() bool
Moves focus to the previous item.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeItem(T item) → void
Removes an item from the selection.
removeItemAt(int index) → void
Removes an item at the given index.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
requestFocus() → void
Requests focus on the search field.
searchNow() → void
Triggers an immediate search with the current text.
selectFocusedItem() → T?
Selects the currently focused item.
setFocusedIndex(int index) → void
Sets focus to a specific index.
setSearchText(String text) → void
Sets the search text programmatically.
setSelectedItems(List<T> items) → void
Sets the selected items programmatically.
showOverlay() → void
Shows the search overlay.
toggleItemSelection(T item) → void
Toggles selection of an item.
toggleOverlay() → void
Toggles the overlay visibility.
toString() String
A string representation of this object.
inherited
unfocus() → void
Removes focus from the search field.

Operators

operator ==(Object other) bool
The equality operator.
inherited