putHandle method

P putHandle(
  1. H key,
  2. P f()
)

Implementation

P putHandle(H key, P Function() f) {
  final existing = to[key];
  if (existing != null) {
    return existing;
  }
  final value = f();
  if (value == nullptr) {
    throw AssertionError('Builder returned null: $key');
  }
  if (from.containsKey(value)) {
    return value;
  }
  acquire(value);
  to[key] = value;
  from[value] = WeakReference(key);
  finalizer.attach(key, value);
  return value;
}