toImage method

Image toImage([
  1. double? pixelRatio
])

Capture the current canvas to an image.

Implementation

ui.Image toImage([double? pixelRatio]) {
  final ctx = _key.currentContext;
  assert(ctx != null);

  final boundary = ctx!.findRenderObject() as RenderRepaintBoundary;
  pixelRatio ??= MediaQuery.of(ctx).devicePixelRatio;
  return boundary.toImageSync(pixelRatio: pixelRatio);
}