getByType static method
dynamic
getByType(
- Type type, {
- bool newInstance = false,
- bool scoppedNewInstance = false,
})
Implementation
static dynamic getByType(Type type,
{bool newInstance = false, bool scoppedNewInstance = false}) {
var key = getKey(type.toString());
if (!_checkKeyExists(key)) {
throw InjectionNotFound("Injection not found from ${type.toString()}.");
}
var ref = _store.where((e) => e.key == key).first;
if (!ref.isSingleton) {
return ref.injectable();
} else {
if (!newInstance) {
var singleton = ref.singleton;
if (singleton == null) {
ref.singleton = ref.injectable();
}
return ref.singleton;
} else {
if (!scoppedNewInstance) {
var newI = ref.injectable();
ref.singleton = newI;
return ref.singleton;
} else {
return ref.injectable();
}
}
}
}