Flutter OnProgressListener for firebase_storage?

1,131

If your upload function is async you can do it like this

  StorageUploadTask putFile =
      storage.ref().child("folder/$fileName").putFile(file);
  putFile.future.catchError(onError);

  UploadTaskSnapshot uploadSnapshot = await putFile.future;

  print("file uploaded");

After the future resolves, the file is uploaded.

Share:
1,131
Jus10
Author by

Jus10

Updated on December 05, 2022

Comments

  • Jus10
    Jus10 over 1 year

    How can we listen to the progress of a file upload to Firebase Storage in Flutter?

    • UpaJah
      UpaJah almost 6 years
      could you find the way to create progress indicator?
  • Jus10
    Jus10 almost 6 years
    I'm looking more for a periodic progress percentage. So I can update the ProgressIndicator
  • Tree
    Tree almost 6 years
    I dont know it can be done. But you can put progress as a spinning circle. CupertinoActivityIndicator
  • Jus10
    Jus10 almost 6 years
    It can be done in Firebase Storage. Just not sure how with the firebase_storage package.