findOrNull<S> method

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

The findOrNull method will return the instance if it is registered; otherwise, it will return null. 如果已注册,则 findOrNull 方法将返回该实例; 否则,它将返回 null.

Implementation

S? findOrNull<S>({String? tag}) {
  if (isRegistered<S>(tag: tag)) {
    return find<S>(tag: tag);
  }
  return null;
}