SearchConfig<T> class
A configuration class that defines how a searchable list behaves.
You can use this class to configure search behavior in a reusable and generic way by passing the list of items, how to render each item, and how to filter them using either a property selector or a custom filter.
Example usage:
SearchConfig<User>(
items: userList,
itemBuilder: (context, user, query) => ListTile(title: Text(user.name)),
propertySelector: (user) => [user.name, user.email],
onItemSelected: (user) => print('Selected: ${user.name}'),
);
Constructors
-
SearchConfig({required List<
T> items, required ItemBuilder<T> itemBuilder, PropertySelector<T> ? propertySelector, ItemFilter<T> ? customFilter, String searchFieldLabel = 'Search...', Widget? noResultsWidget, OnItemSelected<T> ? onItemSelected, Future<List< asyncSearch(String query, int page, int pageSize)?, int pageSize = 10})T> > - are provided, as only one filtering strategy should be used at a time.
Properties
-
asyncSearch
→ Future<
List< Function(String query, int page, int pageSize)?T> > -
Creates a SearchConfig instance for customizing a searchable list.
final
-
customFilter
→ ItemFilter<
T> ? -
A custom function to define how each item should be filtered based
on the search query.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
itemBuilder
→ ItemBuilder<
T> -
A function that builds the UI widget for each item in the result list.
final
-
items
→ List<
T> -
The full list of items to be searched.
final
- noResultsWidget → Widget?
-
A widget to show when there are no matching search results.
final
-
onItemSelected
→ OnItemSelected<
T> ? -
A callback function triggered when a user selects an item.
final
- pageSize → int
-
Throws an AssertionError if both propertySelector and customFilter
Page Size
final
-
propertySelector
→ PropertySelector<
T> ? -
A function that returns the list of string properties to be matched
against the search query.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- searchFieldLabel → String
-
The label to display in the search input field.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited