SqliteDatabase.withFactory constructor

SqliteDatabase.withFactory(
  1. SqliteOpenFactory openFactory, {
  2. int maxReaders = defaultMaxReaders,
})

Advanced: Open a database with a specified factory.

The factory is used to open each database connection in background isolates.

Use when control is required over the opening process. Examples include:

  1. Specifying the path to libsqlite.so on Linux.
  2. Running additional per-connection PRAGMA statements on each connection.
  3. Creating custom SQLite functions.
  4. Creating temporary views or triggers.

Implementation

SqliteDatabase.withFactory(this.openFactory,
    {this.maxReaders = defaultMaxReaders}) {
  updates = _updatesController.stream;

  _listenForEvents();

  _internalConnection = _openPrimaryConnection(debugName: 'sqlite-writer');
  _pool = SqliteConnectionPool(openFactory,
      upstreamPort: _eventsPort.client(),
      updates: updates,
      writeConnection: _internalConnection,
      debugName: 'sqlite',
      maxReaders: maxReaders,
      mutex: mutex);

  _initialized = _init();
}