saveJson method

Future<File> saveJson(
  1. Object? simpleObj
)

Saves the given simple object as JSON (but in a '.db' file). If the file exists, it will be overwritten.

Implementation

Future<File> saveJson(Object? simpleObj) async {
  _checkIfFileSystemIsTheSame();

  Uint8List encoded = encodeJson(simpleObj);

  File file = _file ?? await this.file();
  await file.create(recursive: true);

  return file.writeAsBytes(
    encoded,
    flush: true,
    mode: FileMode.writeOnly,
  );
}