find<S> method

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

Resolves a dependency of type S or identified by key or tag.

Implementation

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