captureImage method
Captures the current visible canvas as an image. Returns a ui.Image which can be used to save or share the graph.
Implementation
@override
Future<ui.Image?> captureImage() async {
try {
final imageBoundary = boundaryRepaintKey.currentContext
?.findRenderObject() as RenderRepaintBoundary?;
if (imageBoundary == null) return null;
return imageBoundary.toImage(pixelRatio: 2.0);
} catch (_) {
return null;
}
}