toDartUiImage method
Implementation
Future<ui.Image> toDartUiImage() async {
await createPaint(key);
if (_boundary != null) {
_imageAsDartUiImage = await _boundary!.toImage(pixelRatio: 6);
} else {
_boundary =
key.currentContext?.findRenderObject() as RenderRepaintBoundary?;
if (_boundary != null) {
// Ensure that the widget is actually rendered on the screen
key.currentContext?.visitChildElements((element) {
final renderObject = element.renderObject;
if (renderObject is RenderRepaintBoundary) {
// Trigger a repaint of the RenderRepaintBoundary
renderObject.markNeedsPaint();
}
});
await Future.delayed(const Duration(milliseconds: 200));
}
_imageAsDartUiImage = await _boundary!.toImage(pixelRatio: 6);
}
return _imageAsDartUiImage;
}