withScope<R> method
Run body with a teardown scope that is ended (and awaited) when body
completes, even on a throw. The async analogue of the synchronous
Context.withScope.
Implementation
Future<R> withScope<R>(
FutureOr<R> Function(AsyncTeardownScope scope) body) async {
final scope = this.scope();
try {
return await body(scope);
} finally {
await scope.end();
}
}