简体   繁体   English

如何将 Flutter 上的图像共享给其他应用程序

[英]How to share image on Flutter to other application

I tried using the https://pub.dartlang.org/packages/share plugin to share an image on my flutter app to other app like Whatsapp, Facebook and so on.我尝试使用https://pub.dartlang.org/packages/share插件将我的 flutter 应用程序上的图像分享到其他应用程序,如 Whatsapp、Facebook 等。 But rather it sending the file name of the image(images/female/ankara/ank5.jpg) in my android project to the other application rather than the actually image.而是将我的android项目中的图像(images/female/ankara/ank5.jpg)的文件名发送到其他应用程序而不是实际图像。

How can make it send the actual image.如何让它发送实际图像。

            Hero(
              tag: widget.imageList,
                child: PhotoView(
                  imageProvider: AssetImage(widget.imageList),
                )
              );


 final RenderBox box = context.findRenderObject();
                        Share.share(widget.imageList,
                            sharePositionOrigin:
                            box.localToGlobal(Offset.zero) &
                            box.size);

I excepted to send the actual image to the other app rather it in a string format.我除外将实际图像发送到另一个应用程序,而不是以字符串格式发送。

As mentioned in the previous comment, you can follow the answer on this Stack Overflow post for sharing images from a Flutter app.正如之前的评论中提到的,您可以按照此 Stack Overflow 帖子中的答案分享来自 Flutter 应用程序的图像。 As for selecting a different image, you can use storage path provider plugins like ext_storage or image_picker .至于选择不同的图像,您可以使用存储路径提供程序插件,如ext_storageimage_picker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM