findOrNull<S> method
Resolves a dependency, or null if not found.
Implementation
S? findOrNull<S>({dynamic key, String? tag}) {
try {
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.findOrNull<S>(tag: tag);
}
return Levit.findOrNull<S>(tag: tag);
} catch (_) {
return null;
}
}