Implementation
static Future<Snapshot?> getSnapshotFromFile(
String id, SnapshotType type, SnapshotTestOptions options) async {
final fileName = getFileName(id, type);
try {
final file = await getSnapshotFile(fileName, options);
final contents = await file.readAsString();
switch (type) {
case SnapshotType.image:
return Snapshot(id, image: asIntList(jsonDecode(contents)));
case SnapshotType.render:
return Snapshot(id, render: contents);
case SnapshotType.layer:
return Snapshot(id, layer: contents);
}
} catch (e) {
print(
'SnapshotTest: (getSnapshotFromFile) snapshot file $fileName not found! - $e');
}
}