untilCalled top-level property Null safety

Future<Invocation> Function<T>(T _()) untilCalled

Returns a future Invocation that will complete upon the first occurrence of the given invocation.

Usage of this is as follows:

await untilCalled(cat.chew());

In the above example, the untilCalled(cat.chew()) will complete only when that method is called. If the given invocation has already been called, the future will return immediately.


Future<Invocation> Function<T>(T Function() _) get untilCalled {
  _untilCalledInProgress = true;
  return <T>(T Function() _) {
    try {
    } catch (_) {
      if (_ is! TypeError) rethrow;
    _untilCalledInProgress = false;
    return _untilCall!.invocationFuture;