predicate<T> function Null safety

Matcher predicate<T>(
  1. bool f(
    1. T
    ),
  2. [String description = 'satisfies function']
)

Returns a matcher that uses an arbitrary function that returns true or false for the actual value.

For example:

expect(v, predicate((x) => ((x % 2) == 0), "is even"))

Implementation

Matcher predicate<T>(bool Function(T) f,
        [String description = 'satisfies function']) =>
    _Predicate(f, description);