【发布时间】:2020-02-29 10:27:46
【问题描述】:
我在我的应用程序中使用“image_picker_web/image_picker_web.dart”。现在,当我选择图像时,显示此图像,它的工作。但是当我尝试将图像保存在存储中时,什么也没有发生。
Uint8List _image1;
Future getImg() async {
Uint8List tempImg = await ImagePickerWeb.getImage(asUint8List: true);
if (tempImg != null) {
setState(() {
// debugPrint(tempImg.toString());
_image1 = tempImg;
});
}}
保存在存储中:
void uploadImg() async {
final StorageReference productImg =
FirebaseStorage.instance.ref().child('ProductImg');
var timekey = DateTime.now();
final StorageUploadTask uploadTask =
productImg.child(timekey.toString() + 'jpg').putData(_image1);
var imageUrl = await (await uploadTask.onComplete).ref.getDownloadURL();
url = imageUrl.toString();
print('Image Url' + url);}
按钮:
RaisedButton(
onPressed: () {
uploadImg();
}
我做错了什么?
【问题讨论】:
-
url在控制台上打印什么? -
什么也不打印。但是调试打印打印 [255, 216, 255, 224, 0, 16, 74,....]
标签: flutter