configureRepositoryLocalStorageSodium function

Override configureRepositoryLocalStorageSodium(
  1. {required CreateFn<Sodium> sodium,
  2. required CreateFn<SecureKey> encryptionKey,
  3. required FutureFn<String> baseDirFn,
  4. bool? clear}
)

Creates an override for hiveLocalStorageProvider using sodium encryption.

This method does the same as the auto-generated variant in main.data.dart, but instead of using the standard (non audited) encryption of hive, sodium is used to encrypt data locally.

Both sodium and the encryptionKey are required as this method does not make sense if encryption is not used. The length of the key must be SodiumHiveCipher.keyBytes.

baseDirFn is also required, as unlike the auto-generated variant, this here is not aware of a possibly installed path_provider. If you want to initially clear all opened repositories, you can set clear to true.

Internally, this method overrides the provider with a SodiumHiveLocalStorage.

Implementation

Override configureRepositoryLocalStorageSodium({
  required CreateFn<Sodium> sodium,
  required CreateFn<SecureKey> encryptionKey,
  required FutureFn<String> baseDirFn,
  bool? clear,
}) =>
    hiveLocalStorageProvider.overrideWithProvider(
      Provider(
        (ref) => SodiumHiveLocalStorage(
          hive: ref.read(hiveProvider),
          sodium: sodium(ref),
          encryptionKey: encryptionKey(ref),
          baseDirFn: baseDirFn,
          clear: clear,
        ),
      ),
    );