find<T> static method

T find<T>({
  1. String? tag,
})

Find a dependency in root scope (throws if not found)

Implementation

static T find<T>({String? tag}) {
  final result = rootScope.find<T>(tag: tag);
  if (result == null) {
    throw Exception(
        'Dependency of type $T${tag != null ? ' with tag $tag' : ''} not found');
  }

  // Auto-initialize ZenService instances when first accessed
  if (result is ZenService && !result.isInitialized) {
    result.ensureInitialized();
  }

  return result;
}