checkPassword static method

Database checkPassword(
  1. Database database,
  2. String? password
)

Checks the password of the database being open, which sqflite returns without configuring it again when its path is already open.

Implementation

static Database checkPassword(
  final Database database,
  final String? password,
) {
  final configuredPassword = _passwords[database];
  // e.g. unknown after a hot restart
  if (configuredPassword != null &&
      configuredPassword != (password ?? _noPassword)) {
    throw DatabaseEncryptionException(
      'The database is already open with another password or without one.',
    );
  }
  return database;
}