put<T> static method

T put<T>(
  1. T instance, {
  2. WireDataLockToken? lock,
})

Store an instance of the object by it's type, and lock it, so it can't be overwritten

Implementation

static T put<T>(T instance, {WireDataLockToken? lock}) {
  final key = instance.runtimeType.toString();
  if (Wire.data(key).isLocked) throw AssertionError(ERROR__CANT_PUT_ALREADY_EXISTING_INSTANCE);
  Wire.data(key, value: instance).lock(lock ?? WireDataLockToken());
  return instance;
}