我正在使用图像选择网,这是很好的工作。我可以用Image.memory()显示图像,但是这个图像以Uintlist8格式显示。为了保存存储需要格式的File,我的问题是如何在Firebase存储中保存图像。
Web图像选择器:
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;
});
}
}发布于 2020-03-03 12:28:59
请试试..。
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);
});
}
}https://stackoverflow.com/questions/60507098
复制相似问题