SmartSearchDropdown<T> class

A convenient widget that combines search functionality with a dropdown overlay showing paginated results from a SmartPaginationCubit.

This widget provides a complete search-with-results solution that can be placed anywhere in your UI. The results dropdown automatically positions itself in the best available space.

Example with provider (creates cubit internally):

SmartSearchDropdown<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),
  ),
  onItemSelected: (product) {
    print('Selected: ${product.name}');
  },
)

Example with external cubit:

SmartSearchDropdown<Product>.withCubit(
  cubit: productSearchCubit,
  searchRequestBuilder: (query) => PaginationRequest(
    page: 1,
    pageSize: 20,
    searchQuery: query,
  ),
  itemBuilder: (context, product) => ListTile(
    title: Text(product.name),
  ),
  onItemSelected: (product) {
    print('Selected: ${product.name}');
  },
)
Inheritance

Constructors

SmartSearchDropdown.withCubit({Key? key, required SmartPaginationCubit<T> cubit, required PaginationRequest searchRequestBuilder(String query), required Widget itemBuilder(BuildContext context, T item), ValueChanged<T>? onItemSelected, 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})
Creates a search dropdown with an external cubit.
const
SmartSearchDropdown.withProvider({Key? key, required PaginationRequest request, required PaginationProvider<T> provider, required PaginationRequest searchRequestBuilder(String query), required Widget itemBuilder(BuildContext context, T item), ValueChanged<T>? onItemSelected, 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, ListBuilder<T>? listBuilder, OnInsertionCallback<T>? onInsertionCallback, int maxPagesInMemory = 5, Logger? logger, RetryConfig? retryConfig, Duration? dataAge, SortOrderCollection<T>? orders})
Creates a search dropdown with an internal cubit.
const

Properties

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
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
loadingBuilder WidgetBuilder?
Builder for the loading state.
final
onItemSelected ValueChanged<T>?
Called when an item is selected.
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
separatorBuilder IndexedWidgetBuilder?
Builder for separators between items.
final
showClearButton bool
Whether to show a clear button.
final
style TextStyle?
Text style for the search input.
final
suffixIcon Widget?
Suffix icon for the search box.
final

Methods

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