onDisposeAsync method
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);
}