commit method

  1. @override
Future<void> commit()
override

Commits all of the writes in this write batch as a single atomic unit.

Calling this method prevents any future operations from being added.

Implementation

@override
Future<void> commit() async {
  if (!_hasUncommittedChanges || isCommitted) {
    return;
  }

  _isCommitted = true;
  _hasUncommittedChanges = false;
  await batch.commit();

  for (var callback in listeners) {
    await callback();
  }
}