snapshotAsImage method

Image snapshotAsImage(
  1. int width,
  2. int height, {
  3. Matrix4? transform,
})

Convert the snapshot to an image with the given width and height. Use transform to position the snapshot in the image, or to apply other transforms before the image is generated.

Implementation

Image snapshotAsImage(int width, int height, {Matrix4? transform}) {
  assert(_picture != null, 'No snapshot has been taken');
  if (transform == null) {
    return _picture!.toImageSync(width, height);
  } else {
    final recorder = PictureRecorder();
    final canvas = Canvas(recorder);
    canvas.transform(transform.storage);
    canvas.drawPicture(_picture!);
    final picture = recorder.endRecording();
    return picture.toImageSync(width, height);
  }
}