share method
Share image with share_plus
Implementation
Future<void> share(BuildContext context) async {
final byteData = await NetworkAssetBundle(Uri.parse(imgUrl)).load(imgUrl);
final bytes = byteData.buffer.asUint8List();
final name = imgUrl.split('/').last;
// ignore: use_build_context_synchronously
final box = context.findRenderObject() as RenderBox?;
final file = XFile.fromData(bytes, name: name, mimeType: 'image/png');
await Share.shareXFiles(
[file],
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
}