FilterList is a flutter plugin which is designed to provide ease in filter data from list of strings.filter_list Plugin
FilterList.showFilterList()
.FilterList.showFilterList()
to display filter dialog.All
button to select all text from list.Reset
button to make all text unselected.Apply
buton to return selected list of strings.close
icon clicked it close dialog and return null value.Apply
button is pressed it will return empty list of string.dependencies:
filter_list: ^0.0.1
import package:filter_list/filter_list.dart';
List<String> countList = [
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
"Eleven",
"Tweleve",
"Thirteen",
"Fourteen",
"Fifteen",
"Sixteen",
"Seventeen",
"Eighteen",
"Nineteen",
"Twenty"
];
List<String> selectedCountList = [];
FilterList.showFilterList()
dialog on button clicked void _openFilterList() async {
var list = await FilterList.showFilterList(
context,
allTextList: countList,
height: 450,
borderRadius: 20,
headlineText: "Select Count",
searchFieldHintText: "Search Here",
selectedTextList: selectedCountList,
);
if (list != null) {
setState(() {
selectedCountList = List.from(list);
});
}
}
_openFilterList
function on floatingActionButton
pressed @override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
floatingActionButton: FloatingActionButton(
onPressed: _openFilterList,
tooltip: 'Increment',
child: Icon(Icons.add),
),
/// check for empty or null value selctedCountList
body: selectedCountList == null || selectedCountList.length == 0
? Center(
child: Text('No text selected'),
)
: ListView.separated(
itemBuilder: (context, index) {
return ListTile(
title: Text(selectedCountList[index]),
);
},
separatorBuilder: (context, index) => Divider(),
itemCount: selectedCountList.length));
}
No selected text from list | FilterList widget | Make selection | Selected text from list |
---|---|---|---|
Hidden close Icon | Hidden text field | Hidden header text | Hidden full header |
---|---|---|---|
Customised control button | Customised selected text | Customised unselected text | Customised text field background color |
---|---|---|---|
height
Type: double
width
Type: double
borderRadius
Type: double
allTextList
Type: List String()
selectedTextList
Type: List String
headlineText
Type: String
searchFieldHintText
Type: String
hideSelectedTextCount
Type: bool
hideSearchField
Type: bool
hidecloseIcon
Type: bool
hideheader
Type: bool
closeIconColor
Type: Color
headerTextColor
Type: Color
applyButonTextColor
Type: Color
applyButonTextBackgroundColor
Type: Color
allResetButonColor
Type: Color
selectedTextColor
Type: Color
selectedTextBackgroundColor
Type: Color
unselectedTextbackGroundColor
Type: Color
unselectedTextColor
Type: Color
searchFieldBackgroundColor
Type: Color
backgroundColor
Type: Color
Author: TheAlphamerc
GitHub: https://github.com/TheAlphamerc/flutter_plugin_filter_list
#flutter #dart #programming