transaction<T> method

Future<T> transaction<T>(
  1. Future<T> action(
    1. Transaction txn
    ),
  2. {bool exclusive}
)

Calls in action must only be done using the transaction object using the database will trigger a dead-lock

await database.transaction((txn) async {
  // Ok
  await txn.execute('CREATE TABLE Test1 (id INTEGER PRIMARY KEY)');

  // DON'T  use the database object in a transaction
  // this will deadlock!
  await database.execute('CREATE TABLE Test2 (id INTEGER PRIMARY KEY)');
});

Implementation

Future<T> transaction<T>(Future<T> Function(Transaction txn) action,
    {bool exclusive});