onDisposeAsync method

void onDisposeAsync(
  1. Future<void> callback()
)

Registers resource cleanup that drainAndDispose will await. After disposal, await the returned disposalComplete for cleanup errors.

Implementation

void onDisposeAsync(Future<void> Function() callback) {
  if (_isDisposed) throw StateError('Scope is disposed');
  _asyncDisposeCallbacks.add(callback);
}