find<S> static method
Find a dependency
Implementation
static S find<S>({String? tag}) {
final type = S;
if (!_dependencies.containsKey(type)) {
throw 'Dependency of type $type not found. Did you forget to call Flows.put()?';
}
final builder = _dependencies[type]![tag];
if (builder == null) {
throw 'Dependency of type $type with tag $tag not found.';
}
if (builder.instance != null) {
return builder.instance as S;
}
if (builder.builder != null) {
final instance = builder.builder!() as S;
builder.instance = instance;
// Call onInit and onReady if it's a controller with lifecycle
if (instance is FlowLifeCycleMixin) {
instance.init();
instance.ready();
}
return instance;
}
throw 'Dependency of type $type not properly initialized.';
}