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 TransactionResult has committed false and the snapshot the handler last saw.
const
factory
Transaction.success(Object? value, {Object? priority})
Commits value, and priority when given, as the location's new data. Without priority the location keeps its current priority, unless value is a map with a .priority key (DatabaseReference.set removes it). The value follows the rules of DatabaseReference.set; it may hold ServerValue placeholders. An invalid value or priority throws neither here nor at runTransaction: the transaction aborts and its Future fails with the ArgumentError.
const
factory

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