未为“StorageUploadTask”类型定义 getter“future”

时间:2021-05-19 19:08:53

标签: android firebase flutter dart file-upload

我正在尝试为用户的个人资料页面实现图片选择器并将图片上传到 Firebase 存储。 它给出了一个错误,比如“没有为类型‘StorageUploadTask’定义getter‘future’。 尝试导入定义 'future' 的库,将名称更正为现有 getter 的名称,或者定义名为 'future' 的 getter 或字段。"

     class _SelectprofilepicPageState extends State<SelectprofilepicPage> {
     File newProfilePic;

     Future getImage() async {
     var tempImage = await ImagePicker.pickImage(source: ImageSource.gallery);
     setState(() {
     newProfilePic = tempImage;
     });
     }

      uploadImage() {
      var randomno = Random(25);
      final StorageReference firebaseStorageRef = FirebaseStorage.instance
    .ref()
    .child('profilepics/${randomno.nextInt(5000).toString()}.jpg');
StorageUploadTask task = firebaseStorageRef.putFile(newProfilePic);

task.future.then((value) {
  userManagement.updateProfilePicture(value.downloadUrl.toString()).then((val) {
    //Navigator.of(context).pushReplacementNamed('/homepage');
  });
}).catchError((e) {
  print(e);
});
}

0 个答案:

没有答案
相关问题