operator [] method

Object operator [](
  1. Type t
)

Implementation

Object operator [](Type t) {
  if (_cache.containsKey(t)) {
    return _cache[t]!;
  }

  final typeName = t.toString();
  final r = map[typeName];
  if (r != null) {
    _cache[t] = r;
    return r;
  }

  final genericIndex = typeName.indexOf("<");
  if (genericIndex == -1) {
    throw ArgumentError("Runtime not found for type '$t'.");
  }

  final genericTypeName = typeName.substring(0, genericIndex);
  final out = map[genericTypeName];
  if (out == null) {
    throw ArgumentError("Runtime not found for type '$t'.");
  }

  _cache[t] = out;
  return out;
}