I am very new to Dart, and coding in general. I have produced this code after watching tutorials on YouTube. For the most part, I have been able to troubleshoot most of my problems on my own, here I feel I need some help. I have written code to upload photographs, but it is giving the following error. Please help me understand this.
I/flutter ( 7512): [firebase_storage/object-not-found] No object exists at the desired reference.
My code is here:-
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 ');
}
}