capture method
Implementation
Future<Uint8List?> capture() async {
try {
await WidgetsBinding.instance.endOfFrame;
final boundary = captureKey.currentContext?.findRenderObject()
as RenderRepaintBoundary?;
if (boundary == null) return null;
final image = await boundary.toImage(pixelRatio: 3.0);
final byteData = await image.toByteData(format: ImageByteFormat.png);
return byteData?.buffer.asUint8List();
} catch (e) {
debugPrint('Screenshot error: $e');
return null;
}
}