executeBatch method
Executes one SQL statement across many parameter sets within this transaction.
await db.transaction((tx) async {
await tx.executeBatch(
'INSERT INTO users(name) VALUES (?)',
[['Ada'], ['Grace'], ['Sonja']],
);
});
Runs as a single isolate round-trip: the flattened param array crosses once, the statement is prepared (or fetched from the writer cache) once, and bind+step is looped entirely in C. The enclosing transaction provides atomicity — no inner BEGIN/COMMIT is issued. On error this throws, and the enclosing scope (top-level transaction or savepoint) rolls back.
Throws StateError if called after the enclosing transaction body has returned.
Implementation
Future<void> executeBatch(
String sql,
List<List<Object?>> paramSets,
) async {
_ensureActive();
await _writer.executeBatch(sql, paramSets);
}