readBackup method
Reads the backup from the selected location.
Returns null
if the backup has not been found or could not be
serialized.
Implementation
Future<BackupModel?> readBackup({
/// The serialization logic.
///
/// The logic will vary from Model class to Model class and must be
/// provided on each read-request.
required BackupModel Function(String) decode,
}) async {
print("Reading Backup...");
try {
final file = await _localFile;
// Read the file
final contents = await file.readAsString();
print("Backup found on ${file.path}");
return decode(contents);
} catch (e) {
print(_notFoundErrorMessage);
print(e.toString());
return null;
}
}