capture method
Implementation
Future<Uint8List?> capture() async {
await Future.delayed(const Duration(milliseconds: 100));
Uint8List? image;
if (!foundation.kIsWeb) {
final boundary = _globalKey.currentContext!.findRenderObject()
as RenderRepaintBoundary?;
if (!foundation.kDebugMode || boundary?.debugNeedsPaint != true) {
final img = await boundary!.toImage(
pixelRatio: _mediaQuery?.devicePixelRatio ?? 1.0,
);
final byteData = await img.toByteData(
format: ui.ImageByteFormat.png,
);
image = byteData?.buffer.asUint8List();
}
}
return image;
}