begin method

Create a batch to safely modify this ProviderModel's ProviderModelVariable members.

A lockKey can be passed to prevent multiple batches from being created at the same time with the same lockKey. If a batch is already in progress with the same lockKey, a ConflictException will be thrown. Every ProviderModel has a default ProviderLockKey that this function will default to if lockKey is not set.

Implementation

@nonVirtual
ProviderModelBatch begin([ProviderLockKey? lockKey]) {
  assert(!_disposed, 'ProviderModel was already disposed.');
  assert(
    Zone.current[#providerModelUseSubscription] == null,
    'begin() cannot be called while a use callback is being executed.',
  );

  lockKey ??= _defaultLockKey;

  if (locked(lockKey)) {
    throw ConflictException(lockKey, this);
  }

  return ProviderModelBatch._internalCreate(this);
}