I am working on a flutter web. I wrote uploadtostorage function to upload the selected image to firestorage. However, I don't know how to get downloadurl from the uploadtask before I saved the downloadurl to firestore. Here is my code.
void uploadToStorage(CurrentUser user) {
final dateTime = DateTime.now();
final uid = user.uid;
final path = '$uid/$dateTime';
uploadImage(onSelected: (file) {
fb
.storage()
.refFromURL('gs://....com')
.child(path)
.put(file)
.future
.then((_) {
// get downloadUrl here
FirebaseFirestore.instance
.collection('users')
.doc(user.uid)
.update({'photo_url': //downloadUrl here});
});
});
}