saveGeneral method
All of the above has been for FHIR resources and data, below is if you need to store whatever else as well
Implementation
Future<int> saveGeneral({
required Object object,
int? key,
String? pw,
}) async {
await _ensureInit(pw: pw);
final HiveAesCipher? cipher = cipherFromKey(key: pw);
try {
final Box<Object> box;
if (!Hive.isBoxOpen('general')) {
box = await Hive.openBox('general', encryptionCipher: cipher);
} else {
box = Hive.box('general');
}
if (key == null) {
return box.add(object);
} else {
await box.put(key, object);
return key;
}
} catch (e) {
return -1;
}
}