addStrongReference method

bool addStrongReference({
  1. required Object instance,
  2. String? instanceId,
})

Add a new instance with instanceId as key and instance as the value.

instance is stored as a strong reference.

Returns true if the pair is successfully added. Returns false if the instanceId or instance is already contained in the manager or the instance is a num, bool, or String.

Implementation

bool addStrongReference({required Object instance, String? instanceId}) {
  if (!_isValidInstance(instance)) return false;

  final String newId = instanceId ?? generateUniqueInstanceId(instance);
  _instanceIds[instance] = newId;
  _strongReferences[newId] = instance;
  return true;
}