FilterListDelegate<T> class

The FilterListDelegate.show implement a search view, using SearchDelegate The listData should be list of T which needs to filter.

the selectedListData should be sub list of listData.

The tileLabel is a callback which required String value in return. It used this value to display text on choice chip.

The suggestionBuilder is a builder that builds a widget for each item available in the search list. If no builder is provided by the user, the package will try to display a ListTile for each child, with a string representation of itself as the title

The searchFieldDecorationTheme is used to configure the search field's visuals.

Only one of searchFieldStyle or searchFieldDecorationTheme can be non-null.

onItemSearch filter the list on the basis of search field query. It expose search api to perform search operation outside the package.

The onApplyButtonClick is a callback which return list of all selected items on apply button click. if no item is selected then it will return empty list.

This example shows how to use FilterListDialog

await FilterListDelegate.show<String>(
    context: context,
    list: ['Jon', 'Abraham', 'John', 'Peter', 'Paul', 'Mary', 'Jane'],
    onItemSearch: (user, query) {
      return user.toLowerCase().contains(query.toLowerCase());
    },
    tileLabel: (user) => user,
    emptySearchChild: Center(child: Text('No user found')),
    enableOnlySingleSelection: true,
    searchFieldHint: 'Search Here..',
    onApplyButtonClick: (list) {
       // do something with list
    },
  );

control buttons to show on bottom of dialog along with 'Apply' button.

If ControlButtonType.All is passed then it will show 'All' and 'Apply' button.

If ControlButtonType.Reset is passed then it will show 'Reset' and 'Apply' button.

Default value is [ControlButton.All, ControlButton.Reset]

If enableOnlySingleSelection is true then it will hide 'All' button.

Inheritance

Constructors

FilterListDelegate({required List<T> listData, List<T>? selectedListData, required SearchPredict<T> onItemSearch, required OnApplyButtonClick<T> onApplyButtonClick, LabelDelegate<T>? tileLabel, bool enableOnlySingleSelection = false, String? searchFieldHint, SuggestionBuilder<T>? suggestionBuilder, InputDecorationTheme? searchFieldDecorationTheme, TextStyle? searchFieldStyle, AppbarBottom? buildAppbarBottom, Widget? emptySearchChild, FilterListDelegateThemeData? theme, ButtonStyle? applyButtonStyle, bool hideClearSearchIcon = false, String applyButtonText = 'Apply'})

Properties

applyButtonStyle ButtonStyle?
final
applyButtonText String
final
automaticallyImplyLeading bool?
Controls whether we should try to imply the leading widget if null.
getter/setter pairinherited
buildAppbarBottom AppbarBottom?
final
emptySearchChild Widget?
Widget built when there's no item in items that matches current query.
final
enableOnlySingleSelection bool
final
hashCode int
The hash code for this object.
no setterinherited
hideClearSearchIcon bool
final
keyboardType TextInputType?
The type of action button to use for the keyboard.
finalinherited
leadingWidth double?
Defines the width of AppBar.leading widget.
getter/setter pairinherited
listData List<T>
final
onApplyButtonClick OnApplyButtonClick<T>
final
onItemSearch SearchPredict<T>
final
query String
The current query string shown in the AppBar.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchFieldDecorationTheme InputDecorationTheme?
The InputDecorationTheme used to configure the search field's visuals.
final
searchFieldHint String?
Search field hint text
final
searchFieldLabel String?
The hint text that is shown in the search field when it is empty.
finalinherited
searchFieldStyle TextStyle?
The style of the searchFieldLabel.
final
selectedItems List<T>?
getter/setter pair
selectedListData List<T>?
final
suggestionBuilder SuggestionBuilder<T>?
final
tempList List<T>
getter/setter pair
textInputAction TextInputAction
The text input action configuring the soft keyboard to a particular action button.
finalinherited
theme FilterListDelegateThemeData?
final
tileLabel LabelDelegate<T>?
final
transitionAnimation Animation<double>
Animation triggered when the search pages fades in or out.
no setterinherited

Methods

appBarTheme(BuildContext context) ThemeData
The theme used to configure the search page.
inherited
buildActions(BuildContext context) List<Widget>
Widgets to display after the search query in the AppBar.
override
buildBottom(BuildContext context) PreferredSizeWidget?
Widget to display across the bottom of the AppBar.
override
buildFlexibleSpace(BuildContext context) Widget?
Widget to display a flexible space in the AppBar.
inherited
buildLeading(BuildContext context) Widget
A widget to display before the current query in the AppBar.
override
buildResults(BuildContext context) Widget
The results shown after the user submits a search from the search page.
override
buildSuggestions(BuildContext context) Widget
Suggestions shown in the body of the search page while the user types a query into the search field.
override
close(BuildContext context, T? result) → void
Closes the search page and returns to the underlying route.
inherited
dispose() → void
Releases the resources.
inherited
isSelected(T item) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onItemSelect(BuildContext context, T item) → void
showResults(BuildContext context) → void
Transition from the suggestions returned by buildSuggestions to the query results returned by buildResults.
inherited
showSuggestions(BuildContext context) → void
Transition from showing the results returned by buildResults to showing the suggestions returned by buildSuggestions.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

show<T>({required BuildContext context, required List<T> list, List<T>? selectedListData, LabelDelegate<T>? tileLabel, required SearchPredict<T> onItemSearch, required OnApplyButtonClick<T> onApplyButtonClick, SuggestionBuilder<T>? suggestionBuilder, String? searchFieldHint, InputDecorationTheme? searchFieldDecorationTheme, TextStyle? searchFieldStyle, AppbarBottom? buildAppbarBottom, bool enableOnlySingleSelection = false, Widget? emptySearchChild, FilterListDelegateThemeData? theme, ButtonStyle? applyButtonStyle, String? applyButtonText = 'Apply'}) Future<T?>?
Shows a full screen search page and returns the search result selected by the user when the page is closed. Open search view page that implement SearchDelegate