New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[proposal] Provide a way to close a specific dialog #62960
Comments
I think the root issue here is in the way the current navigator works. You can't push or pop anything below the current active route. Have you tried using the new navigator 2.0 pages api? I wonder if it's possible to do it in that, where the navigation stack is more malleable. |
@tolotrasamuel explained very accurately. |
I'd like to see this feature too |
I have the same experience as you. In the end, I chose |
The same problem exists in the case of |
Many waiting months later... :/ |
You can play around this final route = DialogRoute(
context: context,
builder: (_)=>MyDialogView(),
barrierDismissible: false
);
Navigator.of(context).push(route);
// close dialog
Navigator.of(context).removeRoute(route);
Or dive into
|
Important to note the following from
You'll probably have to play around with completers and the like to get this to work as expected. |
This comment was marked as abuse.
This comment was marked as abuse.
Using |
any updated? |
any updated? |
Extended showDialog:
Navigation Service:
|
In my case, I needed to open the bottom sheet while closing the dialog, but the sheet was closed instead. |
too,i'm hate the getx and flutter |
Please check this issue. |
This issue is missing a priority label. Please set a priority label when adding the |
2024 👍 |
Use case
Currently, there is no way to close a specific alert dialog.
In Flutter, the only way to close a specific dialog is by this dialoge itself like this
Now what if the parent widget wants to close this dialog? The problem with
Navigator.of(context).pop()
is that it will close the topmost widget on the Navigation stack, not this specific dialog.Consider the following reproducible example to illustrate this issue:
Steps to reproduce:
Copy paste the below code in DartPad.dev/flutter
Hit run
Click the
Do Api Call
buttonyou should see two popups, one below and one above
After 5 seconds, the one below is desired to close not the one above, instead, the one above closes
How to close the one below and leave the one above open ?
Proposal
In Android, you just do:
dialog.dismiss();
In Flutter, there should be a way to get the reference to each specific dialog
Please make this as a
P0
feature request because it is a very basic feature that Android does it so easily and it used so frequently by developers.The text was updated successfully, but these errors were encountered: