save method

Future<void> save()

Implementation

Future<void> save() async {
  try {
    final encKey = encryptionKey ?? _getDefaultKey();
    final json = jsonEncode({
      'value': _value,
      'version': version,
      'timestamp': DateTime.now().toIso8601String(),
    });

    final encrypted = await encryption.encrypt(json, key: encKey);
    await storage.save(storageKey, encrypted);
  } catch (e) {
    debugPrint('Error saving encrypted data: $e');
    rethrow;
  }
}