addObject static method

Future<void> addObject(
  1. String key,
  2. String modelKey,
  3. String modelValue
)

Writes serialized object to a file

Implementation

static Future<void> addObject(
  String key,
  String modelKey,
  String modelValue,
) async {
  LazyBox lazyBox = Hive.lazyBox(cacheName);
  Map<String, String> value;

  if (lazyBox.isOpen) {
    value = (await lazyBox.get(key))?.cast<String, String>() ?? {};
    value.update(
      modelKey,
      (_) => modelValue,
      ifAbsent: () => modelValue,
    );
    await lazyBox.put(key, value);
  }
}