Multiple progress dialog instance in a statefull widget
bagus-repository opened this issue · comments
Describe the bug
I got strange condition if I have multiple progress dialog instance in a Statefull Widget, progress dialogs instantiate on build widget like this
progressDialog = new ProgressDialog(context,
type: ProgressDialogType.Normal, isDismissible: true, showLogs: false)
..style(
message: msg ?? "Memproses...",
borderRadius: 8.0,
backgroundColor: Colors.white,
elevation: 5.0,
messageTextStyle: TextStyle(fontSize: 16.0),
// progressWidget: CircularProgressIndicator(),
);
progressDownloadDialog = new ProgressDialog(context,
isDismissible: false, type: ProgressDialogType.Download)
..style(
message: "Mendownload...",
borderRadius: 8.0,
backgroundColor: Colors.white,
elevation: 5.0,
messageTextStyle: TextStyle(fontSize: 16.0),
progress: 0.0,
maxProgress: 100,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
);
If I call progressDialog.show() or progressDownloadDialog.show(), the progressDownloadDialog will be triggered.
To Reproduce
Steps to reproduce the behavior:
- Go to 'make multiple instance progress dialog'
- Call on '.show()'
- See not properly showing
Expected behavior
I can use multiple ProgressDialog in a StatefullWidget
Screenshots
Not yet
Smartphone (please complete the following information):
- Device: Pixel 3a
- OS: Android
- Version 10
just tell me one thing, why do one require two instances if the work can be done with only one instance
Ah my bad, I do not see the source code, I think the ProgressDialogType just for this purpose
Expanded(
child: _progressDialogType == ProgressDialogType.Normal
? Text(_dialogMessage,
textAlign: TextAlign.justify, style: _messageStyle)
: Stack(
children: <Widget>[
Positioned(
child: Text(_dialogMessage, style: _messageStyle),
top: 30.0,
),
Positioned(
child: Text("$_progress/$_maxProgress",
style: _progressTextStyle),
bottom: 10.0,
right: 10.0,
),
],
),
),
So if I can't instantiate multiple instance (Normal and Download), I would just give the type to ProgressDialogType.Normal and update the percentage in the text instead of progress property.
That's ok, thanks for replying. My suggestion is remove the Type and add child property for customize the content element (you know, just if can be done 😄 )