readJson<T> static method

Future readJson<T>(
  1. String key, {
  2. dynamic defaultValue,
})

Read a JSON value from the local storage

Implementation

static Future<dynamic> readJson<T>(String key, {dynamic defaultValue}) async {
  String? data = await manager().read(key: key);
  if (data == null) {
    return defaultValue;
  }

  try {
    return jsonDecode(data);
  } on Exception catch (e) {
    NyLogger.error(e.toString());
    return null;
  }
}