Flutter-Firestore:- 无法将图像上传到 Firestore。它说找不到参考对象

Flutter-Firestore:- Unable to upload image to firestore. its says reference object is not found

我对 Dart 很陌生,而且一般来说是编码。我在观看 YouTube 上的教程后制作了这段代码。在大多数情况下,我已经能够自己解决大部分问题,在这里我觉得我需要一些帮助。我已经编写了上传照片的代码,但出现以下错误。请帮助我理解这一点。

I/flutter ( 7512): [firebase_storage/object-not-found] No object exists at the desired reference.

我的代码在这里:-

Future uploadImagetoFB() async {
        if (_image != null) {
         try{
           String fileName = Path.basename(_image.path);
           print('The uploaded file name is: ${fileName}');
           final Reference storageReference =
           FirebaseStorage.instance.ref().child('profileImages');
           _imageUrl = await storageReference.getDownloadURL();
           print('The Image Url: $_imageUrl');
         } catch (e){
           print(e);
         }
        }
      }
    
      Future PickedImage(ImageSource source) async {
        try {
          final image = await ImagePicker()
              .pickImage(source: source, maxWidth: 160, maxHeight: 160);
          if (image == null) return;
          setState(() {
            _image = File(image.path);
          });
          uploadImagetoFB();
        } on PlatformException catch (e) {
          print('failed to Upload ');
        }
      }

要将照片上传到 Firebase,请使用以下代码。

这是我设置图片的字符串 url :

  String? url;

图片上传代码:

    uploadImage() async {
    final _firebaseStorage = FirebaseStorage.instance;
    final _imagePicker = ImagePicker();
    PickedFile image;

    //Check Permissions
    await Permission.photos.request();
    var permissionStatus = await Permission.photos.status;
    if (permissionStatus.isGranted) {
      //Select Image
      image = (await _imagePicker.getImage(source: ImageSource.gallery))!;
      var file = File(image.path);
      int uploadTimestamp = DateTime.now().millisecondsSinceEpoch;
      if (image != (null)) {
        Reference ref =
            _firebaseStorage.ref().child('profileImages/$uploadTimestamp');
        UploadTask uploadTask = ref.putFile(file);

        var imageUrl = await (await uploadTask).ref.getDownloadURL();
        setState(() {
          url = imageUrl.toString();
        });
      } else {
        print('No Image Path Received');
      }
    } else {
      print('Permission not granted. Try Again with permission access');
    }
  }

Firebase 的结果:

个人资料图片文件夹:

上传的图片: