MemoryAdapter constructor
MemoryAdapter({
- bool enableEncryption = false,
- String? encryptionKey,
- EncryptionOptions? encryptionOptions,
Creates a new instance of MemoryAdapter.
If enableEncryption
is true, encryptionOptions
must be provided.
Throws an ArgumentError if encryption is enabled but no options are provided.
Implementation
MemoryAdapter({
this.enableEncryption = false,
String? encryptionKey,
EncryptionOptions? encryptionOptions,
}) {
if (enableEncryption) {
if (encryptionOptions != null) {
_encryptionOptions = encryptionOptions;
} else if (encryptionKey != null) {
// For backward compatibility
_encryptionOptions = EncryptionOptions(
algorithm: EncryptionAlgorithm.aes256,
key: encryptionKey,
);
} else {
throw ArgumentError(
'Encryption options or key must be provided when encryption is enabled');
}
_encryption = Encryption(
algorithm: _encryptionOptions!.algorithm,
encryptionKey: _encryptionOptions.key,
);
} else {
_encryptionOptions = null;
}
}