filter_list 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 88

empty_Widget pub package 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.

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 GitHub All Releases #

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 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.2] - 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

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: 450,
      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.3

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]
83
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]
88
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package not compatible with SDK dart

because of import path [filter_list]

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 141 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 273 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 290 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 307 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
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test