dart_filter 1.1.0+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

dart_filter #

High Level Filter Queries for Dart, inspired by the Filter Pattern

Medium Travis CI Codecov License Pub.dev Github Stars Twitter Follow GitHub Follow

dart_filter lets you easily filter dart Lists and Iterables. New requirements oftentimes break naive filtering solutions. dart_filter was made to fix that.


    /// Only adults
    const OnlyAdultsFilter().map((Person p) => p.age),

    /// Only females
    AnonymousCriteria((Person p) => p.sex == Sex.female),

    /// Only names that contain an s
    if (withAnSOnly)
      const ContainsFilter("s", true).map((Person p) => p.name),

class OnlyAdultsFilter extends FilterCriteria<int> {
  const OnlyAdultsFilter();

  bool accepts(int t) => t >= 18;

Each FilterCriteria overrides the call method and therefore acts as a function that you can pass to higher-order functions like .where.

All available FilterCriteria: #

  • AcceptAllCriteria: accepts everything.
  • AcceptNoneCriteria: accepts nothing.
  • AndCriteria (.and or &): accepts an item only if all criteria are met.
  • OrCriteria (.or or |): accepts an item only if at least one of the provided criteria is met.
  • XOrCriteria (.xor): accepts an item only if one of the provided criteria is met.
  • NotCriteria (.not): negates the provided criteria.
  • MapCriteria (.map): use this to map a criteria to a different type.
  • EqualsCriteria: accepts an item only if it is equal (==) to the provided value.
  • AnonymousCriteria: use this to quickly prototype a custom criteria without subclassing FilterCriteria.

There are also some criteria for Lists of Strings:

  • StartsWithFilter: accepts only Strings that start with the provided string.
  • EndsWithFilter: accepts only Strings that end with the provided string.
  • ContainsFilter: accepts only Strings that contain the provided string.

1.1.0+4 (2019-10-26) #

  • badges updated

1.1.0+3 (2019-10-25) #

  • wording

1.1.0+2 (2019-10-25) #

  • typos & Readme badges added

1.1.0+1 (2019-10-24) #

  • typos

1.1.0 (2019-10-24) #

  • Added not/and/xor/or to FilterCriteria

1.0.0 (2019-08-18) #

  • Initial version


A sample command-line application.

Created from templates made available by Stagehand under a BSD-style license.

Use this package as a library

1. Depend on it

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

  dart_filter: ^1.1.0+4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:dart_filter/dart_filter.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.4


Package Constraint Resolved Available
Direct dependencies
Dart SDK >2.2.2 <3.0.0
Dev dependencies
dart_coveralls ^0.6.0
extra_pedantic ^1.0.0
test ^1.6.6
test_coverage ^0.2.0