matchAsync method
Returns null
if this matches item
, or a String description of the
failure if it doesn't match.
This can return a Future or a synchronous value. If it returns a Future, neither expect nor the test will complete until that Future completes.
If this returns a String synchronously, expect will synchronously
throw a TestFailure
and matches will synchronously return false
.
Implementation
@override
dynamic /*FutureOr<String>*/ matchAsync(Object? item) {
if (item is! Function && item is! Future) {
return 'was not a Function or Future';
}
if (item is Future) {
return _matchFuture(item, 'emitted ');
}
try {
item as Function;
var value = item();
if (value is Future) {
return _matchFuture(value, 'returned a Future that emitted ');
}
return indent(prettyPrint(value), first: 'returned ');
} catch (error, trace) {
return _check(error, trace);
}
}