renderImage method

Future<Image> renderImage(
  1. Size size
)

Renders the background and all other drawables to a ui.Image object.

The size of the output image is controlled by size. All drawables will be scaled according to that image size.

Implementation

Future<ui.Image> renderImage(Size size) async {
  final recorder = ui.PictureRecorder();
  final canvas = Canvas(recorder);
  final painter = Painter(
    drawables: value.drawables,
    scale: painterKey.currentContext?.size ?? size,
    background: value.background,
  );
  painter.paint(canvas, size);
  return await recorder
      .endRecording()
      .toImage(size.width.floor(), size.height.floor());
}