putOrFind<S> method
Finds an existing registered instance of type S, or creates and registers a new one
using dep if not already registered.
tagOptional tag to identify the instance.
Implementation
S putOrFind<S>(InstanceBuilderCallback<S> dep, {String? tag}) {
final key = _getKey(S, tag);
if (_singl.containsKey(key)) {
final existing = _singl[key];
if (existing == null) {
return put(dep(), tag: tag);
}
return existing.getDependency() as S;
} else {
return put(dep(), tag: tag);
}
}