specify 1.0.1

  • README.md
  • Installing
  • Versions
  • 35


Specifications allow simple classes to encapsulate business rules in a flexible, testable, and reusable manner.


import 'package:specify/specify.dart';

class StringContains extends Specification<String> {
    final String _substring;
    bool isSatisfiedBy(String aString) => aString.contains(_substring);

class StringNotContains extends StringContains {
    StringNotContains(String aSubstring) : super(aSubstring);
    bool isSatisfiedBy(String aString) => !super.isSatisfiedBy(aString);

class StringIn extends OrSpecification<String> {
    StringIn(List<String> aWordList) : super(
        aWordList.map((String aWord) => new StringContains(aWord)).toList()

class StringNotIn extends AndSpecification<String> {
    StringNotIn(List<String> aWordList) : super(
        aWordList.map((String aWord) => new StringNotContains(aWord)).toList()

main() {
    StringIn    isWord    = new StringIn(['foo', 'bar']);
    StringNotIn isNotWord = new StringNotIn(['baz', 'zim']);



Filtering with specifications can be very powerful, especially when used with CompositeSpecification.

import 'package:specify/specify.dart';

class StringLength extends Specification<String> {
    final int _length;


    bool isSatisfiedBy(String aString) => aString.length == _length;

class LengthFilter extends Filter<String> {
    LengthFilter(int aLength) : super(new StringLength(aLength));

main() {
    LengthFilter filter = new LengthFilter(3);

    print(filter(['foo', 'bar', 'nice', 'to', 'know', 'you']));

Use this package as a library

1. Depend on it

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

  specify: "^1.0.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:specify/specify.dart';
Version Uploaded Documentation Archive
1.1.0 Feb 5, 2017 Go to the documentation of specify 1.1.0 Download specify 1.1.0 archive
1.0.1 Jan 21, 2017 Go to the documentation of specify 1.0.1 Download specify 1.0.1 archive
1.0.0 Jan 19, 2017 Go to the documentation of specify 1.0.0 Download specify 1.0.0 archive


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

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
90 / 100
Reflects how tidy and up-to-date the package is. [more]
42 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:specify/specify.dart.


  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Package is getting outdated.

    The package was released 77 weeks ago.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use specify.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 5 hints.

    Run dartfmt to format lib/src/and_specification.dart.

    Run dartfmt to format lib/src/composite_specification.dart.

    Similar analysis of the following files failed:

    • lib/src/filter.dart (hint)
    • lib/src/or_specification.dart (hint)
    • lib/src/specification.dart (hint)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.15.0 <2.0.0
Dev dependencies
test ^0.12.7