WriteBatch class Null safety

A write batch, used to perform multiple writes as a single atomic unit.

A WriteBatch object can be acquired by calling the Firestore.batch() function. It provides methods for adding writes to the write batch. None of the writes are committed (or visible locally) until WriteBatch.commit() is called.

Unlike transactions, write batches are persisted offline and therefore are preferable when you don't need to condition your writes on read data.

See: firebase.google.com/docs/reference/js/firebase.firestore.WriteBatch.


hashCode int
The hash code for this object. [...]
read-only, inherited
jsObject → WriteBatchJsImpl
JS object.
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


commit() Future<void>
Commits all of the writes in this write batch as a single atomic unit. [...]
delete(DocumentReference documentRef) WriteBatch
Deletes the document referred to by the provided DocumentReference. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
set(DocumentReference documentRef, Map<String, dynamic> data, [SetOptions? options]) WriteBatch
Writes to the document referred to by the provided DocumentReference. If the document does not exist yet, it will be created. If you pass options, the provided data can be merged into the existing document. [...]
toString() String
A string representation of this object. [...]
update(DocumentReference documentRef, {Map<String, dynamic>? data, List? fieldsAndValues}) WriteBatch
Updates fields in the document referred to by this DocumentReference. The update will fail if applied to a document that does not exist. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Methods

getInstance(WriteBatchJsImpl jsObject) WriteBatch
Creates a new WriteBatch from a jsObject.