saveImage method Null safety

Future<bool> saveImage(
  1. SnapshotTestOptions opts,
  2. List<int> img,
  3. {bool? asNew}
)

Implementation

Future<bool> saveImage(SnapshotTestOptions opts, List<int> img,
    {bool? asNew}) async {
  var fileName = getImgFileName(id);
  fileName =
      asNew != null && asNew == true ? getNewImgFileName(id) : fileName;
  try {
    final file = await getSnapshotFile(fileName, opts);
    await file.create();
    await file.writeAsBytes(img);
    return true;
  } catch (e) {
    print('SnapshotTest: (save) failed writing image to file! - $e');
  }
  return false;
}