FilterListDialog class
The FilterListDialog.display is a Dialog with some filter utilities and callbacks which helps in single/multiple selection from list of data.
This example shows how to use FilterListWidget
FilterListWidget<String>(
listData: ["One","Two","Three", "Four","five", "Six","Seven","Eight","Nine","Ten"],
selectedListData: ["One", "Three", "Four", "Eight", "Nine"],
hideHeaderText: true,
height: MediaQuery.of(context).size.height,
// hideHeaderText: true,
onApplyButtonClick: (list) {
Navigator.pop(context, list);
},
choiceChipLabel: (item) {
/// Used to print text on chip
return item;
},
validateSelectedItem: (list, val) {
/// identify if item is selected or not
return list!.contains(val);
},
onItemSearch: (list, text) {
/// When text change in search text field then return list containing that text value
///
///Check if list has value which match's to text
if (list!.any((element) =>
element.toLowerCase().contains(text.toLowerCase()))) {
/// return list which contains matches
return list
.where((element) =>
element.toLowerCase().contains(text.toLowerCase()))
.toList();
}
return [];
},
)
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