Implementation
Future<bool> save(SnapshotTestOptions opts, {bool? asNew}) async {
var fileName = getFileName(id, type);
fileName =
asNew != null && asNew == true ? getNewFileName(id, type) : fileName;
try {
final fileOld = await getSnapshotFile(fileName, opts);
await fileOld.create();
final data = getSnapshotData();
if (data is String) {
await fileOld.writeAsString(data);
} else if (data is List<int>) {
await fileOld.writeAsString(jsonEncode(data));
}
return true;
} catch (e) {
print('SnapshotTest: (save) failed writing data to file! - $e');
}
return false;
}