isInstantiated<S> method

bool isInstantiated<S>({
  1. dynamic key,
  2. String? tag,
})

Whether type S has already been instantiated.

Implementation

bool isInstantiated<S>({dynamic key, String? tag}) {
  if (key is LevitStore) {
    final scope = _ScopeProvider.of(_context) ?? Ls.currentScope;
    return key.isInstantiatedIn(scope, tag: tag);
  }
  if (key is LevitAsyncStore) {
    final scope = _ScopeProvider.of(_context) ?? Ls.currentScope;
    return key.isInstantiatedIn(scope, tag: tag);
  }
  final scope = _ScopeProvider.of(_context);
  if (scope != null) {
    return scope.isInstantiated<S>(tag: tag);
  }
  return Levit.isInstantiated<S>(tag: tag);
}