get<T> method

T? get<T>({
  1. String? tag,
})

Gets the created value from the module

Implementation

T? get<T>({String? tag}) {
  var injectFactory = injectMap[T];

  if (injectFactory != null && injectFactory is InjectTagFactory) {
    // use default tag for TaggedInjectFactory
    var instance =
        injectFactory.createTagged(tag ?? InjectTagFactory.defaultTag);
    return instance;
  } else if (injectFactory != null) {
    if (tag != null && tag != InjectTagFactory.defaultTag) {
      return null; // Dime not provide providing instance,
      // because tagged instance was expected.
    } else {
      var instance = injectFactory.create();
      return instance;
    }
  } else {
    return null;
  }
}