removeScopeHandler method

Future<void> removeScopeHandler(
  1. String scopeName
)

Removes the ScopeHandler that handles the scope with scopeName.

Note: This does not leave the scope itself; use leaveScope for that.

Implementation

Future<void> removeScopeHandler(final String scopeName) async {
  final handler = _scopeHandlers.firstWhereOrNull((final handler) => handler.canHandleScope(scopeName));

  if (handler != null) {
    _scopeHandlers.removeWhere((final e) => e.canHandleScope(scopeName));

    // not calling handler.handle since the scope might not be left yet.
    // ??
    await handler.clearAllRegisteredObjects();
    handler.dispose();
  }
}