SqliteDatabase.singleConnection constructor

SqliteDatabase.singleConnection(
  1. SqliteConnection connection
)

Opens a SqliteDatabase that only wraps an underlying connection.

This function may be useful in some instances like tests, but should not typically be used by applications. Compared to the other ways to open databases, it has the following downsides:

  1. No connection pool / concurrent readers for native databases.
  2. No reliable update notifications on the web.
  3. There is no reliable transaction management in Dart, and opening the same database with SqliteDatabase.singleConnection multiple times may cause "database is locked" errors.

Together with SqliteConnection.synchronousWrapper, this can be used to open in-memory databases (e.g. via SqliteOpenFactory.open). That bypasses most convenience features, but may still be useful for short-lived databases used in tests.

Implementation

factory SqliteDatabase.singleConnection(SqliteConnection connection) {
  return SingleConnectionDatabase(connection);
}