setState is not working in showCupertinoDialog. When i get async data i want to update the progress bar which is inside dialog. _progress value is updated and setstate is called successfully but dialog is not updating. I am using statefulBuilder.
showCupertinoDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text("Preparing..."),
content: StatefulBuilder(builder: (context, StateSetter setState) {
print('ssetstatte');
return UploadIndicator(_progress);
}),
actions: [
CupertinoDialogAction(
onPressed: () {
Navigator.of(context).pop();
},
isDefaultAction: true,
child: Text("Cancel"),
),
],
),
).whenComplete(() {});
_uploadTask.snapshotEvents.listen((event) {
_progress =
event.bytesTransferred.toDouble() / event.totalBytes.toDouble();
/*THIS IS NOT UPDATING DIALOG*/
setState(() {
_progress = double.parse((_progress * 100).toStringAsFixed(2));
});
});