getKey method

dynamic getKey(
  1. Type type,
  2. String? tag
)

Get a key for associating factories and instances with types and tags

Implementation

dynamic getKey(Type type, String? tag) {
  if (tag == null) return type;

  // Use cached key if available
  final cacheKey = '${type.hashCode}:$tag';
  if (_keyCache.containsKey(cacheKey)) {
    return _keyCache[cacheKey];
  }

  final key = '$type:$tag';
  _keyCache[cacheKey] = key;
  return key;
}