captureImage function
- Element element
Render the closest RepaintBoundary of the element
into an image.
See also:
- OffsetLayer.toImage which is the actual method being called.
Implementation
Future<ui.Image> captureImage(Element element) {
assert(element.renderObject != null);
RenderObject renderObject = element.renderObject!;
while (!renderObject.isRepaintBoundary) {
renderObject = renderObject.parent!;
}
assert(!renderObject.debugNeedsPaint);
final OffsetLayer layer = renderObject.debugLayer! as OffsetLayer;
return layer.toImage(renderObject.paintBounds);
}