jsonWriteWrapper method
- Map fn(
- dynamic initialData
A wrapper function that takes care of loading and writing JSON. Pass in a function that takes in the existing data and returns your desired new data, and the wrapper will take care of the rest. Where possible, use writeDataToJson instead - it provides a safer and more high-level API.
Implementation
void jsonWriteWrapper(Map Function(dynamic initialData) fn) {
final rawData = pretLoadJson();
final processedData = fn(rawData);
processedData['schema'] = schemaVersion;
final stringifiedData = encoder.convert(processedData);
_putJson(stringifiedData);
}