FilterList is a flutter plugin which is developed to filter data from a list

  List, packages, Packages, Plugin

empty_Widget

FilterList is a flutter plugin that is designed to provide ease in filter data from a list of strings.

Getting Started

1. Add library to your pubspec.yaml

dependencies:
  filter_list: ^0.0.1

2. Import library in dart file

import 'import 'package:filter_list/filter_list.dart';';

3. How to use FilterList

Create a list of Strings

  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 = [];

Create a function and call 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);
      });
    }
  }

Call _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));
  }

Download App 

Screenshots

ScreenshotScreenshot

Parameters and Value

height
  • Set height of filter dialog.
width
  • Set width of filter dialog.
borderRadius
  • Set border radius of filter dialog.

allTextList

  • Populate filter dialog with text list.

selectedTextList

  • Marked selected text in filter dialog.
headlineText
  • Set header text of filter dialog.
searchFieldHintText
  • Set hint text in search field.

hideSelectedTextCount

  • Hide selected text count.
hideSearchField
  • Hide search text field.
hidecloseIcon
  • Hide close Icon.
hideheader
  • Hide complete header section from filter dialog.
closeIconColor
  • set color of close Icon.
headerTextColor
  • Set color of header text.

applyButonTextColor

  • Set text color of apply button.

applyButonTextBackgroundColor

  • Set background color of apply button.
allResetButonColor
  • Set text color of all and reset button.
selectedTextColor
  • Set color of selected text in filter dialog.
selectedTextBackgroundColor
  • Set background color of selected text field.
unselectedTextbackGroundColor
  • Set background color of unselected text field.

unselectedTextColor

  • Set text color of unselected text in filter dialog
searchFieldBackgroundColor
  • Set background color of Search field.

backgroundColor

  • Set the background color of filter color.

Pull Requests

I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request.

Download FilterList flutter plugin source code on GitHub

https://github.com/TheAlphamerc/flutter_plugin_filter_list