shareScreenshot method
dynamic
shareScreenshot(
takes screenshot and invokes share
Implementation
shareScreenshot(GlobalKey previewContainer, int originalSize, String title,
String name, String mimeType,
{String text = ''}) async {
RenderRepaintBoundary boundary = previewContainer.currentContext!
.findRenderObject() as RenderRepaintBoundary;
double pixelRatio = originalSize /
MediaQuery.of(previewContainer.currentContext!).size.width;
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData!.buffer.asUint8List();
try {
await file(title, name, pngBytes, mimeType, text: text);
} catch (e) {
print('error while sharing: $e');
}
}