createTagged method

  1. @override
T? createTagged(
  1. String? tag
)
override

Method that checks if instance is already in singleton map before creating new instance of T

Implementation

@override
T? createTagged(String? tag) {
  if (tag == null) {
    return _handleDefault();
  }
  var localInstance = taggedSingletons[tag];
  if (localInstance == null) {
    localInstance = createForTag(tag);
    if (localInstance == null) {
      taggedSingletons.remove(tag);
    } else {
      taggedSingletons[tag] = localInstance;
    }
  }
  return localInstance;
}