PowerSyncDatabase constructor

  1. required Schema schema,
  2. required String path,
  3. int maxReaders = SqliteDatabase.defaultMaxReaders,
  4. Logger? logger,
  5. @Deprecated("Use [PowerSyncDatabase.withFactory] instead.") SqliteConnectionSetup? sqliteSetup,

Open a PowerSyncDatabase.

Only a single PowerSyncDatabase per path should be opened at a time.

The specified schema is used for the database.

A connection pool is used by default, allowing multiple concurrent read transactions, and a single concurrent write transaction. Write transactions do not block read transactions, and read transactions will see the state from the last committed write transaction.

A maximum of maxReaders concurrent read transactions are allowed.

logger defaults to autoLogger, which logs to the console in debug builds.


factory PowerSyncDatabase(
    {required Schema schema,
    required String path,
    int maxReaders = SqliteDatabase.defaultMaxReaders,
    Logger? logger,
    @Deprecated("Use [PowerSyncDatabase.withFactory] instead.")
    // ignore: deprecated_member_use_from_same_package
    SqliteConnectionSetup? sqliteSetup}) {
  // ignore: deprecated_member_use_from_same_package
  var factory = PowerSyncOpenFactory(path: path, sqliteSetup: sqliteSetup);
  return PowerSyncDatabase.withFactory(factory,
      schema: schema, logger: logger);