capture method
Implementation
Future<Uint8List?> capture() async {
if (_globalKey?.currentContext == null) return null;
try {
final RenderRepaintBoundary boundary = _globalKey!.currentContext!.findRenderObject()! as RenderRepaintBoundary;
final ui.Image image = await boundary.toImage(pixelRatio: 3);
final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
return byteData?.buffer.asUint8List();
} catch (e) {
debugPrint("Error capturing widget: $e");
return null;
}
}