如何获得我颤抖上传到Firebase的图片的精确参考

问题描述

这是我上传图片代码

 Future uploadProfileImage() async {
    final StorageReference profileImageStorageRef =
        FirebaseStorage.instance.ref().child("Profile Images");
    var currentUserPicture = user.uid.toString();
    final StorageUploadTask profileUploadTask = profileImageStorageRef
        .child(currentUserPicture.toString() + ".jpg")
        .putFile(myImage);
    var imageUrl =
        await (await profileUploadTask.onComplete).ref.getDownloadURL();
    setState(() {
      profilePicUrl = imageUrl.toString();
      print("Image name = " + profilePicUrl);
    });
  }

我的firebase数据存储区中显示的只是“未来”实例

解决方法

我没有立即看到代码中有什么问题,但是一行中有两个'shuterstock_init' only refers to a type,but is being used as a value here 语句使得很难快速扫描正在发生的事情。

我建议像这样重写它:

await