如何从flutter应用程序将图像共享到whatsapp?

pro*_*ion 4 whatsapp flutter

我必须将我的颤振应用程序中的图像直接发送到 whatsapp。启动whatsapp后,我想选择要分享图像的联系人。这在颤振中怎么可能?

我尝试使用 url_launcher,但它正在启动指定的联系人。而且我在任何地方都找不到共享选项。

  const url = 'whatsapp://send?phone=$phone';
   if (await URLLauncher.canLaunch(url)) {
     await URLLauncher.launch(url);
   } 
   else {
     throw 'Could not launch $url';
   }
Run Code Online (Sandbox Code Playgroud)

non*_*hto 8

您可以使用esys_flutter_share在 flutter 中共享文件。您只需要将文件作为字节发送并共享到您想要的任何外部应用程序。

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.'); 
Run Code Online (Sandbox Code Playgroud)

  • 如何直接打开whatsapp?那可能吗? (6认同)