findInScope<T> method

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

Finds a dependency in the current scope

Implementation

T findInScope<T>({String? tag}) {
  final scope = zenScope;
  if (scope == null) {
    throw Exception('No ZenScope found. Use this method within a ZenRoute.');
  }
  final result = scope.find<T>(tag: tag);
  if (result == null) {
    throw Exception(
        'Dependency of type $T${tag != null ? ' with tag $tag' : ''} not found in scope');
  }
  return result;
}