Transaction class sealed
The answer of a TransactionHandler: write a new value with Transaction.success, or stop with
Transaction.abort.
The two answers are TransactionSuccess and TransactionAbort, so a test can switch over a
handler's answer. Adding a subtype is a breaking change and ships only in a major release.
final TransactionResult result = await db.ref('counters/likes').runTransaction(
(Object? current) => Transaction.success(((current as num?) ?? 0) + 1),
);
- Annotations
Constructors
- Transaction.abort()
-
Stops the transaction with no write: the
TransactionResulthascommittedfalse and the snapshot the handler last saw.constfactory - Transaction.success(Object? value, {Object? priority})
-
Commits
value, andprioritywhen given, as the location's new data. Withoutprioritythe location keeps its current priority, unlessvalueis a map with a.prioritykey (DatabaseReference.setremoves it). The value follows the rules ofDatabaseReference.set; it may holdServerValueplaceholders. An invalid value or priority throws neither here nor atrunTransaction: the transaction aborts and its Future fails with the ArgumentError.constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited