[英]How to share image downloaded from flutter
I use flutter to save a widget as an image in flutter.我使用颤振将小部件保存为颤振中的图像。 I have no problem with downloading the image but im having troubke with sharing the image.
我下载图像没有问题,但我在共享图像时遇到了麻烦。 Is there a way i way share the downlaoded image without leaving the application?
有没有办法在不离开应用程序的情况下分享下载的图像?
Here's my present code这是我目前的代码
onPressed: () async {
if (await Permission.storage.request().isGranted) {
screenshotController.capture(pixelRatio: 1.5);
screenshotController.capture().then((File image) async {
await ImageGallerySaver.saveImage(image.readAsBytesSync());
Navigator.of(context, rootNavigator: true).pop();
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text("Image Saved to Gallery"),
duration: const Duration(seconds: 1),
),
);
}).catchError((onError) {
// print(onError);
});
} else {
await Permission.storage.request();
}
}
You need to handle the image as any other file.您需要像处理任何其他文件一样处理图像。
If you do not intend to use a server between the two users, its a bit tricky because one of them must act as one, but if you will use a server, i suggest you to follow this post:如果您不打算在两个用户之间使用服务器,这有点棘手,因为其中一个必须充当一个,但是如果您将使用服务器,我建议您关注这篇文章:
https://dev.to/carminezacc/advanced-flutter-networking-part-1-uploading-a-file-to-a-rest-api-from-flutter-using-a-multi-part-form-data-post-request-2ekm https://dev.to/carminezacc/advanced-flutter-networking-part-1-uploading-a-file-to-a-rest-api-from-flutter-using-a-multi-part-form-data-请求后 2ekm
It's pretty recent and will help you with the app code and even with a server sample writen in nodejs.它是最近的,可以帮助您编写应用程序代码,甚至可以使用 nodejs 编写的服务器示例。 The next parts of the post teach you to do what you want.
帖子的下一部分教你做你想做的事。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.