And*_*han 3 dart flutter flutter-web
我正在使用运行良好的 Image Picker web。我可以在 中显示图像Image.memory(),但此图像的格式为 Uintlist8。为了保存在存储需要格式File,我的问题是如何在Firebase Storage 中保存图像。
网络图片选择器:
class _SecondPageState extends State<SecondPage> {
final _formkey = GlobalKey<FormState>();
Uint8List _image;
getImage() async {
Uint8List tempImg = await ImagePickerWeb.getImage(asUint8List: true);
if (tempImg != null) {
setState(() {
_image = tempImg;
});
}
}
Run Code Online (Sandbox Code Playgroud)
小智 7
请尝试 ....
final _formkey = GlobalKey<FormState>();
Uint8List _image;
getImage() async {
Uint8List tempImg = await ImagePickerWeb.getImage(asUint8List: true);
if (tempImg != null) {
setState(() {
_image = tempImg;
final tempDir = await getTemporaryDirectory();
final file = await new File('${tempDir.path}/image.jpg').create();
file.writeAsBytesSync(_image);
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5346 次 |
| 最近记录: |