storeJson static method

Future storeJson(
  1. String key,
  2. dynamic object, {
  3. bool inBackpack = false,
})

Saves a JSON object to local storage.

Implementation

static Future storeJson(String key, object, {bool inBackpack = false}) async {
  if (inBackpack == true) {
    Backpack.instance.set(key, object);
  }

  try {
    return await StorageManager.storage
        .write(key: key, value: jsonEncode(object));
  } on Exception catch (e) {
    NyLogger.error(e.toString());
    NyLogger.error(
        '[NyStorage.store] Failed to store $object to local storage. Please ensure that the object is a valid JSON object.');
  }
}