SmartSearchMultiDropdown<T> class

A widget that provides multi-selection search functionality with a dropdown.

This widget allows users to search and select multiple items. The selected items are displayed below the search box with individual remove buttons.

Example with provider:

SmartSearchMultiDropdown<Product>.withProvider(
  request: PaginationRequest(page: 1, pageSize: 20),
  provider: PaginationProvider.future((request) async {
    return await api.searchProducts(request.searchQuery ?? '');
  }),
  searchRequestBuilder: (query) => PaginationRequest(
    page: 1,
    pageSize: 20,
    searchQuery: query,
  ),
  itemBuilder: (context, product) => ListTile(
    title: Text(product.name),
  ),
  onSelectionChanged: (products) {
    print('Selected ${products.length} items');
  },
)

Example with showSelected:

SmartSearchMultiDropdown<Product>.withProvider(
  // ... other properties
  showSelected: true,
  selectedItemBuilder: (context, product, onRemove) => Chip(
    label: Text(product.name),
    onDeleted: onRemove,
  ),
)
Inheritance

Constructors

SmartSearchMultiDropdown.withCubit({Key? key, required SmartPaginationCubit<T> cubit, required PaginationRequest searchRequestBuilder(String query), required Widget itemBuilder(BuildContext context, T item), ValueChanged<List<T>>? onSelectionChanged, SmartSearchConfig searchConfig = const SmartSearchConfig(), SmartSearchOverlayConfig overlayConfig = const SmartSearchOverlayConfig(), InputDecoration? decoration, TextStyle? style, Widget? prefixIcon, Widget? suffixIcon, bool showClearButton = true, BorderRadius? borderRadius, WidgetBuilder? loadingBuilder, WidgetBuilder? emptyBuilder, Widget errorBuilder(BuildContext context, Exception error)?, IndexedWidgetBuilder? separatorBuilder, WidgetBuilder? headerBuilder, WidgetBuilder? footerBuilder, BoxDecoration? overlayDecoration, bool showSelected = true, Widget selectedItemBuilder(BuildContext context, T item, VoidCallback onRemove)?, List<T>? initialSelectedValues, int? maxSelections, String? validator(String?)?, TextInputAction textInputAction = TextInputAction.search, List<TextInputFormatter>? inputFormatters, AutovalidateMode? autovalidateMode, ValueChanged<String>? onChanged, int? maxLength, TextCapitalization textCapitalization = TextCapitalization.none, TextInputType keyboardType = TextInputType.text, bool selectedItemsWrap = true, double selectedItemsSpacing = 8.0, double selectedItemsRunSpacing = 8.0, EdgeInsets selectedItemsPadding = const EdgeInsets.only(top: 12)})
Creates a multi-selection search dropdown with an external cubit.
const
SmartSearchMultiDropdown.withProvider({Key? key, required PaginationRequest request, required PaginationProvider<T> provider, required PaginationRequest searchRequestBuilder(String query), required Widget itemBuilder(BuildContext context, T item), ValueChanged<List<T>>? onSelectionChanged, SmartSearchConfig searchConfig = const SmartSearchConfig(), SmartSearchOverlayConfig overlayConfig = const SmartSearchOverlayConfig(), InputDecoration? decoration, TextStyle? style, Widget? prefixIcon, Widget? suffixIcon, bool showClearButton = true, BorderRadius? borderRadius, WidgetBuilder? loadingBuilder, WidgetBuilder? emptyBuilder, Widget errorBuilder(BuildContext context, Exception error)?, IndexedWidgetBuilder? separatorBuilder, WidgetBuilder? headerBuilder, WidgetBuilder? footerBuilder, BoxDecoration? overlayDecoration, bool showSelected = true, Widget selectedItemBuilder(BuildContext context, T item, VoidCallback onRemove)?, List<T>? initialSelectedValues, int? maxSelections, String? validator(String?)?, TextInputAction textInputAction = TextInputAction.search, List<TextInputFormatter>? inputFormatters, AutovalidateMode? autovalidateMode, ValueChanged<String>? onChanged, int? maxLength, TextCapitalization textCapitalization = TextCapitalization.none, TextInputType keyboardType = TextInputType.text, bool selectedItemsWrap = true, double selectedItemsSpacing = 8.0, double selectedItemsRunSpacing = 8.0, EdgeInsets selectedItemsPadding = const EdgeInsets.only(top: 12), ListBuilder<T>? listBuilder, OnInsertionCallback<T>? onInsertionCallback, int maxPagesInMemory = 5, Logger? logger, RetryConfig? retryConfig, Duration? dataAge, SortOrderCollection<T>? orders})
Creates a multi-selection search dropdown with an internal cubit.
const

Properties

autovalidateMode AutovalidateMode?
When to validate the input.
final
borderRadius BorderRadius?
Border radius for the search box.
final
decoration InputDecoration?
Decoration for the search text field.
final
emptyBuilder WidgetBuilder?
Builder for the empty state.
final
errorBuilder Widget Function(BuildContext context, Exception error)?
Builder for the error state.
final
footerBuilder WidgetBuilder?
Builder for a footer in the dropdown.
final
hashCode int
The hash code for this object.
no setterinherited
headerBuilder WidgetBuilder?
Builder for a header in the dropdown.
final
initialSelectedValues List<T>?
The initially selected values.
final
inputFormatters List<TextInputFormatter>?
Input formatters to restrict or format input.
final
itemBuilder Widget Function(BuildContext context, T item)
Builder for each result item.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType
The type of keyboard to display.
final
loadingBuilder WidgetBuilder?
Builder for the loading state.
final
maxLength int?
Maximum length of the input.
final
maxSelections int?
Maximum number of items that can be selected.
final
onChanged ValueChanged<String>?
Called when the text changes.
final
onSelectionChanged ValueChanged<List<T>>?
Called when the selection changes.
final
overlayConfig SmartSearchOverlayConfig
Configuration for the overlay appearance.
final
overlayDecoration BoxDecoration?
Decoration for the overlay container.
final
prefixIcon Widget?
Prefix icon for the search box.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchConfig SmartSearchConfig
Configuration for search behavior.
final
searchRequestBuilder PaginationRequest Function(String query)
Builds the pagination request for a search query.
final
selectedItemBuilder Widget Function(BuildContext context, T item, VoidCallback onRemove)?
Builder for displaying selected items.
final
selectedItemsPadding EdgeInsets
Padding around the selected items container.
final
selectedItemsRunSpacing double
Spacing between selected items vertically (when wrapped).
final
selectedItemsSpacing double
Spacing between selected items horizontally.
final
selectedItemsWrap bool
Whether to wrap selected items or use horizontal scroll.
final
separatorBuilder IndexedWidgetBuilder?
Builder for separators between items.
final
showClearButton bool
Whether to show a clear button.
final
showSelected bool
Whether to show selected items below the search box.
final
style TextStyle?
Text style for the search input.
final
suffixIcon Widget?
Suffix icon for the search box.
final
textCapitalization TextCapitalization
Text capitalization behavior.
final
textInputAction TextInputAction
The action button on the keyboard.
final
validator String? Function(String?)?
Validator function for form validation.
final

Methods

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