flutter - 将此png保存到颤振的电话画廊
问题描述
void _show(PictureDetails picture, BuildContext context) {
setState(() {
_finished = true;
});
Navigator.of(context)
.push(new MaterialPageRoute(builder: (BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: const Text('your image'),
),
body: new Container(
alignment: Alignment.center,
child: new FutureBuilder<Uint8List>(
future: picture.toPNG(),
builder:
(BuildContext context, AsyncSnapshot<Uint8List> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
if (snapshot.hasError) {
return new Text('Error: ${snapshot.error}');
} else {
return Image.memory(snapshot.data!);
}
default:
return new Container(
child: new FractionallySizedBox(
widthFactor: 0.1,
child: new AspectRatio(
aspectRatio: 1.0,
child: new CircularProgressIndicator()),
alignment: Alignment.center,
));
}
},
)),
);
}));
} }
此类在屏幕上显示 png 图像,但下一步是将其保存到手机图库。我尝试了许多依赖项将图像保存到图库,但不幸的是它们都不适合我。我想在屏幕上的任何地方都有一个按钮,按下该按钮,图像就会保存在画廊中。
解决方案
推荐阅读
- c++11 - 如何使用 curl 库代码(不是命令,我想使用 libcurl 作为静态库)使用 C++ 从谷歌驱动器显示/下载/上传文件?
- vue.js - Vue - 更改另一个命名视图时保持默认路由器视图活动
- reactjs - React-native:在不同的屏幕中删除 BackHandler
- java - 如何在 Android API 16 中使用 MediaSessionManager?
- bitbucket-server - 我可以在 preUpdate 中获取当前用户(atlassian bitbucket 插件)
- python - Python - 多条件条件
- angular - Angular:自定义管道事件处理
- bash - MacOS catalina Makefile 无法正确处理在 CLI 中工作的 shell 命令
- spacy - 添加正则表达式以停止 spacy 中的单词
- google-chrome - 非隐身模式下的vscode chrome调试器