getSnapshotFromFile method Null safety

Future<Snapshot?> getSnapshotFromFile(
  1. String id,
  2. SnapshotType type,
  3. SnapshotTestOptions options
)

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');
  }
}