如何从flutter应用程序共享图像到whatsapp? [英] How to share image to whatsapp from flutter application?
本文介绍了如何从flutter应用程序共享图像到whatsapp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须将图像从我的flutter应用程序直接发送到whatsapp.启动whatsapp后,我想选择联系人以共享图像.怎么可能在扑打?
I have to send an image from my flutter application to whatsapp directly. After launching the whatsapp, I want to select the contacts to share the image. How this possible in flutter?
我尝试使用url_launcher,但它正在启动指定的联系人.而且我在任何地方都找不到共享选项.
I tried using url_launcher, but it is launching the specified contact. And I couldn't find the sharing option anywhere.
const url = 'whatsapp://send?phone=$phone';
if (await URLLauncher.canLaunch(url)) {
await URLLauncher.launch(url);
}
else {
throw 'Could not launch $url';
}
推荐答案
您可以使用 esys_flutter_share 共享文件.您只需要将文件发送为字节并共享到所需的任何外部应用程序即可.
You can make use of esys_flutter_share to share files in flutter. You just need to send a file as bytes and share to any external application you want.
final ByteData bytes = await rootBundle.load('assets/image1.png');
await Share.file('esys image', 'esys.png', bytes.buffer.asUint8List(), 'image/png', text: 'My optional text.');
这篇关于如何从flutter应用程序共享图像到whatsapp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文