captureImage method

void captureImage(
  1. dynamic onCapture(
    1. CaptureResult
    )
)

Implementation

void captureImage(Function(CaptureResult) onCapture) async {
  WidgetsBinding.instance!.addPostFrameCallback((_) async {
    final boundary = _boundaryKey.currentContext!.findRenderObject()
        as RenderRepaintBoundary;
    final image = await boundary.toImage(pixelRatio: 2);
    final data = await image.toByteData(format: ImageByteFormat.png);
    onCapture(
        CaptureResult(data!.buffer.asUint8List(), image.width, image.height));
  });
}