IsolationLevel enum

Defines the consistency and visibility guarantees for a transaction.

The isolation level determines how a transaction sees changes made by other concurrent transactions, and what guarantees it has about the stability of the data it reads.

When to use

Choose the isolation level based on your consistency requirements:

  • readCommitted – for simple, independent updates where you don't care about concurrent modifications.
  • repeatableRead – when you need a stable view of the data during the transaction, and want to abort if another transaction changes it.
  • serializable – when you need full isolation with no write skew, at the cost of performance and global ordering.

How it works

  • readCommitted: Reads return the current live value. No snapshot is taken. This is the default and fastest option.
  • repeatableRead: A snapshot is taken at begin. Reads return the snapshot value. During commit, if any participant has changed since the snapshot, the transaction aborts with a conflict.
  • serializable: Like repeatable read, but also tracks the read set. If any cell that was read (but not written) has changed, the transaction aborts. Commits are globally serialized.
Inheritance
Available extensions

Values

readCommitted → const IsolationLevel

Read Committed – the default level.

Reads return the current live value at the time of the read. No snapshot is taken. This provides the best performance and the least consistency guarantees.

When to use

  • Simple updates that don't depend on reading stable values.
  • High‑throughput scenarios where consistency can be relaxed.
  • When you only need atomicity for writes, not isolation for reads.
repeatableRead → const IsolationLevel

Repeatable Read – ensures a stable view of participant cells.

A snapshot of all participant cells is taken at begin. All reads return the snapshot value. During commit, if any participant has changed since the snapshot, the transaction aborts with a TransactionConflictException.

When to use

  • When you need to read a set of values and base updates on them, and you want to ensure no other transaction changes them.
  • For scenarios like "read balance, then deduct amount" where you need consistency.
serializable → const IsolationLevel

Serializable – the strongest isolation level.

Like repeatable read, but also tracks the read set. If any cell that was read (but not written) has changed since the snapshot, the transaction aborts. Commits are globally serialized via a single gate, ensuring a total order of all serializable transactions.

When to use

  • When you need full isolation with no anomalies.
  • For invariants that span multiple cells (e.g., "sum of accounts must be zero").
  • When you can tolerate the performance overhead of global ordering.

Properties

hashCode → int
The hash code for this object.
no setterinherited
index → int
A numeric identifier for the enumerated value.
no setterinherited
name → String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
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

Constants

values → const List<IsolationLevel>
A constant List of the values in this enum, in order of their declaration.