toImage method
Implementation
Future<ui.Image> toImage({Duration? wait, double pixelRatio = 1.0}) async {
buildOwner.buildScope(_root);
if (wait != null) {
await Future.delayed(wait);
}
buildOwner.finalizeTree();
pipelineOwner.flushLayout();
pipelineOwner.flushCompositingBits();
pipelineOwner.flushPaint();
final image =
await renderView!.repaintBoundary!.toImage(pixelRatio: pixelRatio);
final ByteData? byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
return image;
}