Session constructor

Session(
  1. CommonDatabase database, {
  2. String name = 'main',
})

Creates a new session on the given CommonDatabase and the optional name of the schema to track.

Important: While package:sqlite3 uses native finalizers on both the database and the session object to ensure they're cleared automatically once they're no longer used in Dart, the order in which the objects are cleared matters. It is important that the session is closed is before the database, closing it afterwards may crash.

This ordering can't be guaranteed with native finalizers alone. For this reason, returned Sessions should be Session.deleted explicitly as soon as they're no longer needed.

Implementation

factory Session(CommonDatabase database, {String name = 'main'}) {
  final asImpl = database as DatabaseImplementation;
  return SessionImplementation.createSession(asImpl, name);
}