writeBackup method

Future<File> writeBackup(
  1. BackupModel backup
)

Creates a backup file based on the provided BackupModel's content.

Implementation

Future<File> writeBackup(BackupModel backup) async {
  final File file = await _localFile;
  print("Writing Backup content to file on ${file.path}");

  // Serialize to a `Map` object on the model itself.
  final Map<String, dynamic> map = backup.toJson();

  // The encoded `JSON` content
  final String json = jsonEncode(map);

  // Write the content to the file
  return file.writeAsString(json);
}