Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is the "original" code
final key = await secureStorage.read(key: 'key');
final encryptionKey = base64Url.decode(key!);
print('Encryption key: $encryptionKey');
final encryptedBox= await Hive.openBox('vaultBox', encryptionCipher: HiveAesCipher(encryptionKey));
1- the variable encryptionKey is declared as final on top, so it could not be final
2- the variable encryptionKey is typed as String? so it does not match with the return of .decode() -> Uint8List
3- because of these, the example code does not work
I propose this :
encryptionKey = await secureStorage.read(key: 'key');
final key = base64Url.decode(encryptionKey!);
print('Encryption key: $key');
final encryptedBox= await Hive.openBox('vaultBox', encryptionCipher: HiveAesCipher(key));