getOrCreateUserScope method

ZenithUserScope getOrCreateUserScope(
  1. String id
)

Returns the existing ZenithUserScope for id, or creates one.

Implementation

ZenithUserScope getOrCreateUserScope(String id) {
  if (_scopes.containsKey(id)) {
    final existing = _scopes[id]!;
    if (existing is ZenithUserScope) return existing;
    // Dispose the existing base scope to prevent a memory leak before replacing it
    existing.dispose();
  }
  final scope = ZenithUserScope(id);
  _scopes[id] = scope;
  return scope;
}