0

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});
   });
 });
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Hee
  • 187
  • 4
  • 13
  • does [this answer](https://stackoverflow.com/questions/59160998/flutter-how-can-i-get-url-from-firebase-storage-in-firestore) your question ? – Methkal Khalawi Nov 16 '20 at 13:08
  • This is for a flutter web. I can get downloadUrl for my flutter app, but can't for my flutter web. Please let me know how to get downloadUrl for my flutter web. – Hee Nov 16 '20 at 22:00

0 Answers0