capture method
Implementation
Future<Uint8List?> capture({
double? pixelRatio,
Duration delay = const Duration(milliseconds: 20),
}) {
//Delay is required. See Issue https://github.com/flutter/flutter/issues/22308
return new Future.delayed(delay, () async {
try {
ui.Image? image = await captureAsUiImage(
delay: Duration.zero,
pixelRatio: pixelRatio,
);
ByteData? byteData =
await image?.toByteData(format: ui.ImageByteFormat.png);
image?.dispose();
Uint8List? pngBytes = byteData?.buffer.asUint8List();
return pngBytes;
} catch (Exception) {
throw (Exception);
}
});
}