You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
openDialog / openGeneralDialog should not force use of root Navigator #23565
I would like to have a useRootNavigator parameter (which may default to true to ensure backwards compatibility) for openDialog and openGeneralDialog, so that you have the option to use the nearest Navigator instance instead of the furthest one.
This would save me a lot of headaches for having to pass an extra context to my dialog (and further down in the tree) to access a useful context instead of the context of the top navigator.
The "headaches" are simply that I need the context of the nearest Navigator to find back my inherited widgets (incl. correct Theme etc.), that in my case aren't available in the context of the topmost Navigator. By explicitly passing the caller context to the modal widget as an extra parameter I am able to find them, but in case the modal is becoming more complex (using a larger tree with more generic widgets) this is no longer a viable solution.
[✓] Flutter (Channel dev, v0.10.1, on Linux, locale en_US.UTF-8)
• Flutter version 0.10.1 at /home/jos/flutter1/flutter
• Framework revision 6a3ff018b1 (9 days ago), 2018-10-18 18:38:26 -0400
• Engine revision 3860a43379
• Dart version 2.1.0-dev.7.1.flutter-b99bcfd309
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.0)
• Android SDK at /home/jos/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.0
• Java binary at: /home/jos/flutter1/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.1)
• Android Studio at /home/jos/flutter1/android-studio
• Flutter plugin version 27.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1024-b01)
This makes tedious and difficult to show dialogs inside other Navigatos that is not the default one, like this:
My suggestion is to change the signatures of showGeneralDialog and showDialog (and other related methods) to include an option parameter "useRootNavigator" that will be true as default so it will not break noone's code.
This makes tedious and difficult to show dialogs inside other Navigatos that is not the default one
Totally agree. @shinayser how did you manage to show the dialog inside a nested navigator?
I copy and pasted the code from showDialog and showGeneralDialog, wich contains the call to the Navigator.of(context, rootNavigator: true) passing false as the "rootNavigator".
@shinayser thanks for explaining.
I really hope your suggestion will be accepted, I think it is good and a small change.
In case someone from the team is looking for more motivation to fix this, my headache is that I would like to implement a PinCode screen that prompts the user when the app is resumed from background and I would like to push that screen to the root navigator, while the rest of the app is pushed in a nested navigator. It is the safest way I found to implement it without worrying that some dialog will be pushed on top of the PinCode screen due to unexpected event.
This dialog behavior prevents me from doing it and makes me code lots of non elegant changes.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
zoechi commentedon Oct 27, 2018
what kind of headaches are those?
Can you please provide a minimal reproduction that allows to understand your problem better?
Please also add the output of
flutter doctor -v.josvos commentedon Oct 27, 2018
The "headaches" are simply that I need the context of the nearest Navigator to find back my inherited widgets (incl. correct Theme etc.), that in my case aren't available in the context of the topmost Navigator. By explicitly passing the caller context to the modal widget as an extra parameter I am able to find them, but in case the modal is becoming more complex (using a larger tree with more generic widgets) this is no longer a viable solution.
shinayser commentedon Jul 12, 2019
The current implementation of
showDialog(and its variants) always pick the root navigator as below:This makes tedious and difficult to show dialogs inside other Navigatos that is not the default one, like this:
My suggestion is to change the signatures of
showGeneralDialogandshowDialog(and other related methods) to include an option parameter "useRootNavigator" that will be true as default so it will not break noone's code.roeierez commentedon Aug 6, 2019
Totally agree. @shinayser how did you manage to show the dialog inside a nested navigator?
shinayser commentedon Aug 6, 2019
I copy and pasted the code from showDialog and showGeneralDialog, wich contains the call to the
Navigator.of(context, rootNavigator: true)passing false as the "rootNavigator".roeierez commentedon Aug 6, 2019
@shinayser thanks for explaining.
I really hope your suggestion will be accepted, I think it is good and a small change.
In case someone from the team is looking for more motivation to fix this, my headache is that I would like to implement a PinCode screen that prompts the user when the app is resumed from background and I would like to push that screen to the root navigator, while the rest of the app is pushed in a nested navigator. It is the safest way I found to implement it without worrying that some dialog will be pushed on top of the PinCode screen due to unexpected event.
This dialog behavior prevents me from doing it and makes me code lots of non elegant changes.
github-actions commentedon Aug 15, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.