find<T> method
Search and return one instance T from the hashmap
Implementation
T find<T>({String? tag}) {
final key = _getKey(T, tag);
// check if the dependency was already injected
final inVars = _vars.containsKey(key);
if (inVars) {
return _vars[key]!.dependency as T;
}
// if the dependency is a lazy
final inLazyVars = _lazyVars.containsKey(key);
if (inLazyVars) {
final lazy = _lazyVars[key]!;
final dependency = lazy.builder();
_vars[key] = Singleton<T>(
dependency,
autoRemove: lazy.autoRemove,
onRemove: (lazy as dynamic).onRemove,
);
return dependency;
}
throw AssertionError(
'Cannot find $key, make sure call to Get.i.put<${T.toString()}>(), Get.i.lazyPut<${T.toString()}>(), or Get.i.factoryPut<${T.toString()}>() before call find.',
);
}