get<T extends Object> method
Retrieves a dependency of type T
or subtypes of T
registered under
the specified groupEntity
.
If the dependency exists, it is returned; otherwise, a DependencyNotFoundException is thrown.
The return type is a FutureOr, which means it can either be a Future or a resolved value.
If the dependency is registered as a non-future, the returned value will always be non-future. If it is registered as a future, the returned value will initially be a future. Once that future completes, its resolved value is re-registered as a non-future, allowing future calls to this method to return the resolved value directly.
Implementation
FutureOr<T> get<T extends Object>({
Entity? groupEntity,
bool traverse = true,
}) {
final groupEntity1 = groupEntity ?? focusGroup;
final value = getOrNull<T>(
groupEntity: groupEntity1,
traverse: traverse,
);
if (value == null) {
throw DependencyNotFoundException(
type: T,
groupEntity: groupEntity1,
);
}
return value;
}