cleanup method

void cleanup()

Implementation

void cleanup() {
  setTransactionContextPropagator(null);
  final contexts = _ownedContexts.toList();
  _ownedContexts.clear();
  _generation++;
  _fallback.stack.clear();
  Object? firstError;
  StackTrace? firstStack;
  for (final context in contexts) {
    try {
      context.cleanup();
    } catch (error, stack) {
      firstError ??= error;
      firstStack ??= stack;
    }
  }
  if (firstError != null) {
    Error.throwWithStackTrace(firstError, firstStack ?? StackTrace.current);
  }
}