buildRuntimeKey static method

Key buildRuntimeKey(
  1. Type type, [
  2. Key? key
])

Generates the internal Key used in the registry for a given type and optional key.

Implementation

static Key buildRuntimeKey(Type type, [Key? key]) {
  if (key == null) return Key(type.toString());
  if (key is ValueKey) {
    final value = key.value;
    final prefix = '$type.';
    if (value is String && value.startsWith(prefix)) {
      return key;
    }
    return Key('$type.$value');
  }
  return Key('$type.$key');
}