i am trying to upload the image to firebase and get the URL in firestore. It does upload the image but it does not get the URL to Firestore.
this is how i get the image.
Future getImage1() async {
// ignore: deprecated_member_use
var firstImage = await ImagePicker.pickImage(
source: ImageSource.gallery, imageQuality: 65);
setState(() {
_image1 = firstImage;
});
}
this is how i upload and get the url.
uploadPic() async {
Reference ref = storage.ref().child("image1" + DateTime.now().toString());
UploadTask uploadTask = ref.putFile(_image1);
uploadTask.then((res) {
String url = res.ref.getDownloadURL().toString();
imageUrl1 = url;
return url;
});
}
this is how i get the link in firestore
"image 1 Url":(_image1 != null) ? await uploadPic() : null,