'what are the steps to use a variable in my widget with provider

I have this code in a method of a class

UploadTask uploadTask = ref.putData(file);
    uploadTask.snapshotEvents.listen((event) {
      var progress = event.bytesTransferred.toDouble() / event.totalBytes.toDouble();
    });

I'd like to use the variable progress in my widget and i want it to update in realtime

What are the steps to do it ? do i have to suscribe to the stream uploadTask.snapshotEvents.listen ? Or can i just watch the progress variable ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source