matcher 0.12.0+2

  • Installing
  • Versions
  • 78

Support for specifying test expectations, such as for unit tests.

The matcher library provides a third-generation assertion mechanism, drawing inspiration from Hamcrest.

For more information, see Unit Testing with Dart.


  • Fix all strong-mode warnings.


  • Fix test files to use test instead of unittest pkg.


  • Moved a number of members to the unittest package.

    • TestFailure, ErrorFormatter, expect, fail, and 'wrapAsync'.
    • completes, completion, throws, and throwsA Matchers.
    • The Throws class.
    • All of the throws...Error Matchers.
  • Removed FailureHandler, DefaultFailureHandler, configureExpectFailureHandler, and getOrCreateExpectFailureHandler. Now that expect is in the unittest package, these are no longer needed.

  • Removed the name parameter for isInstanceOf. This was previously deprecated, and is no longer necessary since all language implementations now support converting the type parameter to a string directly.


  • Fix a bug introduced in 0.11.4+5 in which operator matchers broke when taking lists of matchers.


  • Fix all strong-mode warnings.


  • Deprecate the name parameter to isInstanceOf. All language implementations now support converting the type parameter to a string directly.


  • Fix the examples for equalsIgnoringWhitespace.


  • Improve the formatting of strings that contain unprintable ASCII characters.


  • Correctly match and print Strings containing characters that must be represented as escape sequences.


  • Remove the type checks in the isEmpty and isNotEmpty matchers and simply access the isEmpty respectively isNotEmpty fields. This allows them to work with custom collections. See Issue 21792 and Issue 21562


  • Fix the prints matcher test on dart2js.


  • Add a prints matcher that matches output a callback emits via print.


  • Add an isNotEmpty matcher.


  • Refactored libraries and tests.

  • Fixed spelling mistake.


  • Added isNaN and isNotNaN matchers.


  • Removed deprecated matchers.


  • Get the tests passing when run on dart2js in minified mode.


  • Compare sets order-independently when using equals().


  • Removed @deprecated annotation on matchers due to Issue 19173


  • Added types to a number of constants.


  • Matchers related to bad language use have been removed. These represent code structure that should rarely or never be validated in tests.

    • isAbstractClassInstantiationError
    • throwsAbstractClassInstantiationError
    • isFallThroughError
    • throwsFallThroughError
  • Added types to a number of method arguments.

  • The structure of the library and test code has been updated.

1. Depend on it

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

  matcher: "^0.12.0+2"

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 packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:matcher/matcher.dart';
Version Uploaded Documentation Archive
0.12.1+4 Sep 20, 2017 Go to the documentation of matcher 0.12.1+4 Download matcher 0.12.1+4 archive
0.12.1+3 Sep 5, 2017 Go to the documentation of matcher 0.12.1+3 Download matcher 0.12.1+3 archive
0.12.1+2 Aug 30, 2017 Go to the documentation of matcher 0.12.1+2 Download matcher 0.12.1+2 archive
0.12.1+1 May 27, 2017 Go to the documentation of matcher 0.12.1+1 Download matcher 0.12.1+1 archive
0.12.1 May 5, 2017 Go to the documentation of matcher 0.12.1 Download matcher 0.12.1 archive
0.12.0+2 Mar 24, 2016 Go to the documentation of matcher 0.12.0+2 Download matcher 0.12.0+2 archive
0.12.0+1 May 21, 2015 Go to the documentation of matcher 0.12.0+1 Download matcher 0.12.0+1 archive
0.12.0 Apr 30, 2015 Go to the documentation of matcher 0.12.0 Download matcher 0.12.0 archive
0.11.4+6 Mar 24, 2016 Go to the documentation of matcher 0.11.4+6 Download matcher 0.11.4+6 archive
0.11.4+5 Mar 24, 2016 Go to the documentation of matcher 0.11.4+5 Download matcher 0.11.4+5 archive

All 26 versions...


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

  • Dart: 2.0.0-dev.31.0
  • pana: 0.10.3


Describes how popular the package is relative to other packages. [more]
94 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
5 / 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:matcher/matcher.dart.


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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Fix issues reported by dartanalyzer or dartfmt.

    dartanalyzer or dartfmt reported 7 hints.

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

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

    Similar analysis of the following files failed:

    • lib/src/iterable_matchers.dart (hint)
    • lib/src/numeric_matchers.dart (hint)
    • lib/src/pretty_print.dart (hint)
    • lib/src/string_matchers.dart (hint)
  • 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 matcher.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
Dev dependencies
test >=0.12.0 <0.13.0