filter_list 0.0.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

filter_list Plugin #

pub package Codemagic build status GitHub last commit Open Source Love GitHub GitHub stars GitHub forks

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

Download App GitHub All Releases #

Data flow #

  • Pass list of strings to FilterList.showFilterList().
  • Pass list of selected strings to show pre-selected text otherwise ignore it.
  • Invoke method FilterList.showFilterList() to display filter dialog.
  • Make selection from list.
  • Click All button to select all text from list.
  • Click Reset button to make all text unselected.
  • Click Apply buton to return selected list of strings.
  • On close icon clicked it close dialog and return null value.
  • Without making any selection Apply button is pressed it will return empty list of string.

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

Screenshots #

No selected text from listFilterList widgetMake selectionSelected text from list
Hidden close IconHidden text fieldHidden header textHidden full header
Customised control buttonCustomised selected textCustomised unselected textCustomised text field background color

Parameters and Value #

height Type: double

  • Set height of filter dialog.

width Type: double

  • Set width of filter dialog.

borderRadius Type: double

  • Set border radius of filter dialog.

allTextList Type: List<String>()

  • Populate filter dialog with text list.

selectedTextList Type: List<String>()

  • Marked selected text in filter dialog.

headlineText Type: String

  • Set header text of filter dialog.

searchFieldHintText Type: String

  • Set hint text in search field.

hideSelectedTextCount Type: bool

  • Hide selected text count.

hideSearchField Type: bool

  • Hide search text field.

hidecloseIcon Type: bool

  • Hide close Icon.

hideheader Type: bool

  • Hide complete header section from filter dialog.

closeIconColor Type: Color

  • set color of close Icon.

headerTextColor Type: Color

  • Set color of header text.

applyButonTextColor Type: Color

  • Set text color of apply button.

applyButonTextBackgroundColor Type: Color

  • Set background color of apply button.

allResetButonColor Type: Color

  • Set text color of all and reset button.

selectedTextColor Type: Color

  • Set color of selected text in filter dialog.

selectedTextBackgroundColor Type: Color

  • Set background color of selected text field.

unselectedTextbackGroundColor Type: Color

  • Set background color of unselected text field.

unselectedTextColor Type: Color

  • Set text color of unselected text in filter dialog

searchFieldBackgroundColor Type: Color

  • Set background color of Search field.

backgroundColor Type: Color

  • Set 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.

Created & Maintained By #

Sonu Sharma (Twitter) (Youtube) (Insta) Twitter Follow

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕

[0.0.1] - 02 Mar 2020 #

  • Filter list functionality added
  • Return selected list of text

[0.0.2] - 02 Mar 2020 #

  • Added filter pop-up theme customization

[0.0.3] - 02 Mar 2020 #

  • Added pop-up height
  • Added pop-up width
  • Added header hide option
  • Added search field hide option
  • Added cross icon hide option

[0.0.4] - 05 Mar 2020 #

  • Added pop-up Corner Radius property
  • Added rippple effect on control button.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      debugShowCheckedModeBanner: false,
      home: MyHomePage(title: 'Filter list plugin demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  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 = [];

  void _openFilterList() async {
    var list = await FilterList.showFilterList(
      context,
      allTextList: countList,
      height: 480,
      borderRadius: 20,
      headlineText: "Select Count",
      searchFieldHintText: "Search Here",
      selectedTextList: selectedCountList,
    );
    
    if (list != null) {
      setState(() {
        selectedCountList = List.from(list);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _openFilterList,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
        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));
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  filter_list: ^0.0.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:filter_list/filter_list.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
84
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • filter_list that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/filter_list_widget.dart. (-1.99 points)

Analysis of lib/src/filter_list_widget.dart reported 4 hints:

line 145 col 34: 'headline' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline5. This feature was deprecated after v1.13.8..

line 282 col 60: 'headline' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline5. This feature was deprecated after v1.13.8..

line 301 col 60: 'headline' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline5. This feature was deprecated after v1.13.8..

line 318 col 60: 'headline' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is headline5. This feature was deprecated after v1.13.8..

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test