configureConnection method

  1. @override
void configureConnection(
  1. Database database,
  2. SqliteOpenOptions options
)

Runs pragmaStatements for a freshly opened connection,

Implementation

@override
void configureConnection(Database database, SqliteOpenOptions options) {
  if (encryptionOptions case final encryption?) {
    final resolved = EncryptedSqliteVariant.resolveOnDatabase(database);
    if (resolved == null) {
      throw UnsupportedError(
        'Tried to use encryption, but neither SQLCipher or '
        'SQLite3MultipleCiphers is available. Consult the documentation on '
        'EncryptionOptions on how to resolve this.',
      );
    }

    for (final pragma in encryption.pragmaStatements(variant: resolved)) {
      database.execute(pragma);
    }
  }

  super.configureConnection(database, options);
}