android - 如何分享从颤振下载的图像
问题描述
我使用颤振将小部件保存为颤振中的图像。我下载图像没有问题,但我在分享图像时遇到了麻烦。有没有办法在不离开应用程序的情况下共享下载的图像?
这是我现在的代码
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();
}
}
解决方案
您需要像处理任何其他文件一样处理图像。
如果您不打算在两个用户之间使用服务器,这有点棘手,因为其中一个必须充当一个,但如果您将使用服务器,我建议您关注这篇文章:
它是最新的,可以帮助您编写应用程序代码,甚至是用 nodejs 编写的服务器示例。这篇文章的下一部分教你做你想做的事。
推荐阅读
- sql - 如何在分层数据中获取所有父母的所有孩子
- c# - 如何使用 c# 从 shell:AppsFolder 虚拟文件夹中检索项目及其详细信息?
- ffmpeg - 在 concat 情况下更改 FFmpeg 输出视频的帧速率
- r - 如何从字符串中包含维度的字符串列中提取产品维度?
- javascript - 使用javascript下载多个文件
- entity-framework - 具有自身外键的 Net Core ApplicationUser
- python - 如何改变熊猫的周期
- sql - 为什么我的 T-SQL 查询在不同的窗口中返回不同?
- javascript - 更改数据表单元格背景功能
- java - Java:Autowired.Value 在哪里寻找设置?