I have written an upload function that uploads the selected files to Firebase Storage.
I can listen to the upload task and print the upload progress but I cannot somehow display it on a progress bar.
I even tried to display the progress as text on the alert dialogue but it always shows 0.00%
This is my upload Function:
uploadData() async {
storageReference.putData(
fileToUpload, SettabelMetaData(
contentType: 'image/*')
).snapshotEvents.listen((event) async {
setState(() {
_progress = event.bytesTransferred.toDouble() /
event.totalBytes.toDouble();
});
debugPrint(_progress.toString());
showDialog(
context: context,
builder: (ctx) {
return AlertDialog(
backgroundColor: Colors.black,
actions: [
LinearProgressIndicator(
value: _progress,
backgroundColor: Colors.white,
color: Colors.red.shade700,
)
],
title: Text(
'Uploading...',
style: GoogleFonts.ubuntu(color: Colors.white),
),
);
});
}
}
please let me know if I am doing anything wrong here, any suggestions will be of great help