FilterListDialog class
The FilterListDialog.display is a Dialog with some filter utilities and callbacks which helps in single/multiple selection from list of data.
The listData
should be list of dynamic data which needs to filter.
The selectedListData
should be sub list of listData
. The list passed to selectedListData
should available in listData
.
The choiceChipLabel
is a callback which required String value in return. It used this value to display text on choice chip.
The validateSelectedItem
used to identifies weather a item is selected or not.
onItemSearch
filter the list on the basis of search field text. It expose search api to perform search operation according to requirement.
When text change in search text field then return a list of element which contains specific text. if no element found then it should return empty list.
The choiceChipBuilder
is a builder to design custom choice chip.
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.
The useSafeArea
argument is used to indicate if the dialog should only display in 'safe' areas of the screen not used by the operating system (see SafeArea for more details). It is true by default, which means the dialog will not overlap operating system areas. If it is set to false the dialog will only be constrained by the screen size. It can not be null.
The useRootNavigator
argument is used to determine whether to push the dialog to the Navigator furthest from or nearest to the given context. By default, useRootNavigator is true and the dialog route created by this method is pushed to the root navigator. It can not be null.
The routeSettings
argument is passed to showGeneralDialog, see RouteSettings for details.
The insetPadding
is the amount of padding added to MediaQueryData.viewInsets on the outside of the dialog.
This defines the minimum space between the screen's edges and the dialog.
Defaults to EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0).
This example shows how to use FilterListDialog
void _openFilterDialog() async {
await FilterListDialog.display<String>(context,
listData: ["One", "Two", "Three", "Four","five","Six","Seven","Eight","Nine","Ten"],
selectedListData: ["One", "Three", "Four","Eight","Nine"],
choiceChipLabel: (item) {
return item;
},
validateSelectedItem: (list, val) {
return list!.contains(val);
},
onItemSearch: (data, query) {
return data!.toLowerCase().contains(query.toLowerCase());
},
height: 480,
borderRadius: 20,
headlineText: "Select Count",
searchFieldHintText: "Search Here",
onApplyButtonClick: (list) {
if (list != null) {
setState(() {
var selectedList = List.from(list);
});
Navigator.pop(context);
}
});
}
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.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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
Static Methods
-
display<
T extends Object> (BuildContext context, {FilterListThemeData? themeData, required List< T> listData, List<T> ? selectedListData, required LabelDelegate<T> choiceChipLabel, required ValidateSelectedItem<T> validateSelectedItem, ValidateRemoveItem<T> ? validateRemoveItem, required SearchPredict<T> onItemSearch, required OnApplyButtonClick<T> onApplyButtonClick, double? height, double? width, double borderRadius = 20, String? headlineText, bool hideSelectedTextCount = false, bool hideSearchField = false, bool hideCloseIcon = false, Widget? headerCloseIcon, bool hideHeader = false, bool barrierDismissible = true, bool useSafeArea = true, RouteSettings? routeSettings, bool enableOnlySingleSelection = false, Color backgroundColor = Colors.white, String? applyButtonText = 'Apply', String? resetButtonText = 'Reset', String? allButtonText = 'All', String? selectedItemsText = 'selected items', EdgeInsets? insetPadding = const EdgeInsets.symmetric(horizontal: 32.0, vertical: 24.0), ChoiceChipBuilder? choiceChipBuilder, List<ControlButtonType> ? controlButtons}) → Future