Undefined class StorageReference when using Firebase Storage

后端 未结 3 1194
甜味超标
甜味超标 2020-12-02 02:43

i am trying to upload image, and the same process is working for my other app, but here it gives these errors, can you guy plz help?

Future getImage1() async          


        
3条回答
  •  半阙折子戏
    2020-12-02 03:28

    As mentioned by @PeterHadad there are a few breaking changes in firebase storage 5.0.1. The classes have been renamed but maintain most of their old functionalities.

    You can also use .whenComplete() to get the download URL as follows-

    uploadPic(File _image1) async {
       FirebaseStorage storage = FirebaseStorage.instance;
       String url;
       Reference ref = storage.ref().child("image1" + DateTime.now().toString());
       UploadTask uploadTask = ref.putFile(_image1);
       uploadTask.whenComplete(() {
          url = ref.getDownloadURL();
       }).catchError((onError) {
        print(onError);
        });
       return url;
    }
    

提交回复
热议问题