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) {
    final createdInstance = createForTag(tag);
    taggedSingletons[tag] = createdInstance;
    return createdInstance;
  } else {
    return localInstance;
  }
}