getInstanceByType method

dynamic getInstanceByType({
  1. required Type type,
})

Implementation

dynamic getInstanceByType({required Type type}){
  if (_registry.containsKey(type) == false) {
    throw new Exception("Type $type is not registered for initialization");
  } else {
    final initializer = _registry[type]!;
    return initializer();
  }
}