findOrNull<S> static method

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

Retrieves the registered instance of type S, or returns null if not found.

  • key: A specific key or LevitState to resolve.
  • tag: The unique identifier used during registration.

Implementation

static S? findOrNull<S>({dynamic key, String? tag}) {
  if (key is LevitState) {
    try {
      return key.findIn(Ls.currentScope, tag: tag) as S;
    } catch (_) {
      return null;
    }
  }
  return Ls.findOrNull<S>(tag: tag);
}