NativeDatabase.opened constructor

NativeDatabase.opened(
  1. Database database, {
  2. bool logStatements = false,
  3. DatabaseSetup? setup,
  4. bool closeUnderlyingOnClose = true,
})

Creates a drift executor for an opened database from the sqlite3 package.

When the closeUnderlyingOnClose argument is set (which is the default), calling QueryExecutor.close on the returned NativeDatabase will also CommonDatabase.dispose the database passed to this constructor.

Using NativeDatabase.opened may be useful when you want to use the same underlying Database in multiple drift connections. Drift uses this internally when running integration tests for migrations.

If logStatements is true (defaults to false), generated sql statements will be printed before executing. This can be useful for debugging. The optional setup function can be used to perform a setup just after the database is opened, before drift is fully ready. This can be used to add custom user-defined sql functions or to provide encryption keys in SQLCipher implementations.

Implementation

factory NativeDatabase.opened(Database database,
    {bool logStatements = false,
    DatabaseSetup? setup,
    bool closeUnderlyingOnClose = true}) {
  return NativeDatabase._(
      _NativeDelegate.opened(database, setup, closeUnderlyingOnClose),
      logStatements);
}