toImage static method
Capture as a ui.Image (useful for in-app display / compositing).
Implementation
static Future<ui.Image?> toImage(
GlobalKey key, {
double pixelRatio = 2.0,
}) async {
if (!_isValidPixelRatio(pixelRatio)) return null;
final boundary =
key.currentContext?.findRenderObject() as RenderRepaintBoundary?;
return boundary?.toImage(pixelRatio: pixelRatio);
}