onRead method

  1. @override
Future<Map<String, dynamic>> onRead(
  1. Stateful node
)
override

Implementation

@override
Future<Map<String, dynamic>> onRead(Stateful node) async {
  File file = _fileFor(node);
  if (!file.existsSync()) {
    return Future.value({});
  }

  String c = await file.readAsString();

  try {
    return Future.value(jsonDecode(c));
  } catch (e, es) {
    logger.warn(
        "Failed to decode JSON for ${node.storageKey} at ${file.path}. Returning empty map. $e");
    logger.warn(es);
  }

  return Future.value({});
}