captureWidgetImage method
Implementation
Future<Uint8List?> captureWidgetImage({required GlobalKey globalKey}) async {
try {
RenderRepaintBoundary? boundary = globalKey.currentContext
?.findRenderObject() as RenderRepaintBoundary?;
ui.Image? image = await boundary?.toImage(pixelRatio: 3.0);
ByteData? byteData =
await image?.toByteData(format: ui.ImageByteFormat.png);
Uint8List? pngBytes = byteData?.buffer.asUint8List();
return pngBytes!;
} catch (ex, trace) {
logError(ex, trace: trace, position: 'captureWidgetImage');
}
return null;
}