beginTransaction method

  1. @override
void beginTransaction()
override

Starts a transaction; nesting is an error.

Implementation

@override
void beginTransaction() {
  if (_insideTransaction) {
    throw StateError(
      'runInTransaction called when an existing transaction is already in progress.',
    );
  }
  _insideTransaction = true;
  _transactionSuccessful = false;
  _snapshot = _Snapshot(
    Map<WriteId, UserWriteRecord>.of(_writes),
    Map<int, TrackedQuery>.of(_trackedQueries),
    <int, Set<ChildKey>>{
      for (final MapEntry<int, Set<ChildKey>> e in _trackedQueryKeys.entries)
        e.key: Set<ChildKey>.of(e.value),
    },
    _serverCacheWrite,
  );
}