findOrNullAsync<S> static method
Asynchronously retrieves the registered instance of type S, or returns null.
key: A specific key or LevitState to resolve.tag: The unique identifier used during registration.
Implementation
static Future<S?> findOrNullAsync<S>({dynamic key, String? tag}) async {
if (key is LevitState) {
try {
final result = await key.findAsyncIn(Ls.currentScope, tag: tag);
if (result is Future) return await result as S?;
return result as S?;
} catch (_) {
return null;
}
}
return Ls.findOrNullAsync<S>(tag: tag);
}