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
[animations] Make OpenContainer work with named routes #51399
I want to implement OpenContainer for existing named routes. We use named routes to track the users path through the app with NavigatorObserver. Using anonymous routes makes this hard.
Proposal
Don't hide _OpenContainerRoute and provide something like a OpenContainerRouteArguments instance in the OpenContainerBuilder to manually navigate.
This ticket is important to support iOS swipe back gesture and to get a pop result from a route.
Reacted by Mehmet Esen, Tom Gilder, srombs, Nathaniel O. Ogunye, Britannio Jarrett, Hector Aguero, Nils Reichardt, Marcos Antônio, Leonardo Salazar, TAJAOUART Mounir and 6 more
Scenario is that we push a new screen using OpenContainer and from within container, I have an action that triggers a bottom. Choosing a specific option in that bottom sheet triggers an alert dialog. If the user taps "save" in that alert dialog, I need to close both the dialog and the bottom sheet. I attempted to use popUntil(ModalRoute.withName('routeName') but because it wasn't pushed as a named route, it's throwing an error.
I'm also waiting for this. For commercial/professional app, it's almost a must... I attempted to mimic Navigation.pop behaviour but, that iOS dragging from left behavior is whole another thing to implement.
Can't use OpenContainer in production because of lack of this feature.
Reacted by srombs, Nils Reichardt, Shashi Kiran R, Yuval Candel, Roman Ismagilov, Loraine Lesch, Hector Aguero, Toni Birka, Zony-Zhao, TAJAOUART Mounir and 4 more
In your onGenerateRoute method use the OpenContainerRoute from the step 2 to load the route final dynamic arguments = route.arguments as Map; return OpenContainerRoute( closedColor: arguments['closedColor'], openColor: arguments['openColor'], closedElevation: arguments['closedElevation'], openElevation: arguments['openElevation'], closedShape: arguments['closedShape'], openShape: arguments['openShape'], closedBuilder: arguments['closedBuilder'], openBuilder: arguments['openBuilder'], hideableKey: arguments['hideableKey'], closedBuilderKey: arguments['closedBuilderKey'], transitionDuration: arguments['transitionDuration'], transitionType: arguments['transitionType'], );
Note: This is just a workaround. I am sure the actual solution is much simpler when it is available.
Hi Britanio, I have tried to use this feature but I cannot seem to figure it out. The openBuilder parameter still is required and is used to navigate to the next page. Even though I have a named route in my RouteSettings object that I pass to the routeSettings parameter.
Would it be possible to provide us with a quick snippet of how this should work?
Yes, specifying routeSettings doesn't defer open builder to an existing named route but it does allow the route name to be picked up with a NavigatorObserver provided to MaterialApp which I believe is what this issue is tracking.
Well yes and no. I personally don't consider this solved but that might not be clear from my initial issue description.
I am looking for a way to push a named route with arguments (let's say ID in a Master <-> Detail transition) via Navigator or Nav 2.0. When I push a detail view it should automatically pick up the correct item in the master view and animate it, and also the reverse when popping the detail.
Especially with Nav 2.0 this gets even more important, everything is declarative but the OpenContainer transition has to be started imperatively.
Reacted by Kavin Varnan, Amit Kotlovski, crissCM, Miguel de Sousa, David Butts, mQBy, thezjy, Adam Bridges and Cory Martin
Hi Britanio, I have tried to use this feature but I cannot seem to figure it out. The openBuilder parameter still is required and is used to navigate to the next page. Even though I have a named route in my RouteSettings object that I pass to the routeSettings parameter.
Would it be possible to provide us with a quick snippet of how this should work?
Many thanks in advance!
I managed to make this work in Nav 1.0 with this setup:
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
georgeherby commentedon Mar 2, 2020
I have just a created a PR on the packages repo for adding RouteSettings to OpenContainer. I think this should do what you want :)
kuhnroyal commentedon Mar 4, 2020
Not exactly, I am looking for a built in way to use this in
onGenerateRoute.nilsreichardt commentedon Mar 6, 2020
This ticket is important to support iOS swipe back gesture and to get a pop result from a route.
jamesdixon commentedon Mar 30, 2020
Also running into a need for this.
Scenario is that we push a new screen using
OpenContainerand from within container, I have an action that triggers a bottom. Choosing a specific option in that bottom sheet triggers an alert dialog. If the user taps "save" in that alert dialog, I need to close both the dialog and the bottom sheet. I attempted to usepopUntil(ModalRoute.withName('routeName')but because it wasn't pushed as a named route, it's throwing an error.esenmx commentedon Apr 1, 2020
I'm also waiting for this. For commercial/professional app, it's almost a must... I attempted to mimic Navigation.pop behaviour but, that iOS dragging from left behavior is whole another thing to implement.
srombs commentedon May 9, 2020
I would also love to have this ability. I am running into the same problem as @AndroidNils
Pomis commentedon May 11, 2020
Can't use OpenContainer in production because of lack of this feature.
asidt commentedon May 25, 2020
I also would like to have this possibility.
shashkiranr commentedon May 29, 2020
any update on this. This is a requirement.
shashkiranr commentedon Jun 1, 2020
I found a workaround to use on onGenerateRoute for OpenContainer. I am sure there is a better way to do this.
ModalRoute<void>toPageRoute<void>final String openBuilderRouteName;await Navigator.of(context, rootNavigator: widget.useRootNavigator).push(MyOpenContainerRoute(...))in Future openContainer() and addawait Navigator.of(context).pushNamed(widget.openBuilderRouteName, arguments: { 'closedColor': widget.closedColor, 'openColor': widget.openColor, 'closedElevation': widget.closedElevation, 'openElevation': widget.openElevation, 'closedShape': widget.closedShape, 'openShape': widget.openShape, 'closedBuilder': widget.closedBuilder, 'openBuilder': widget.openBuilder, 'hideableKey': _hideableKey, 'closedBuilderKey': _closedBuilderKey, 'transitionDuration': widget.transitionDuration, 'transitionType': widget.transitionType, });final dynamic arguments = route.arguments as Map; return OpenContainerRoute( closedColor: arguments['closedColor'], openColor: arguments['openColor'], closedElevation: arguments['closedElevation'], openElevation: arguments['openElevation'], closedShape: arguments['closedShape'], openShape: arguments['openShape'], closedBuilder: arguments['closedBuilder'], openBuilder: arguments['openBuilder'], hideableKey: arguments['hideableKey'], closedBuilderKey: arguments['closedBuilderKey'], transitionDuration: arguments['transitionDuration'], transitionType: arguments['transitionType'], );Note: This is just a workaround. I am sure the actual solution is much simpler when it is available.
britannio commentedon Feb 6, 2021
flutter/packages#240 should have fixed this issue.
4 remaining items
wmla419 commentedon Apr 21, 2021
Can you provide an example of how to use the function?
JarroVGIT commentedon May 10, 2021
Hi Britanio, I have tried to use this feature but I cannot seem to figure it out. The openBuilder parameter still is required and is used to navigate to the next page. Even though I have a named route in my RouteSettings object that I pass to the routeSettings parameter.
Would it be possible to provide us with a quick snippet of how this should work?
Many thanks in advance!
britannio commentedon May 11, 2021
Yes, specifying
routeSettingsdoesn't defer open builder to an existing named route but it does allow the route name to be picked up with aNavigatorObserverprovided toMaterialAppwhich I believe is what this issue is tracking.kuhnroyal commentedon May 11, 2021
Well yes and no. I personally don't consider this solved but that might not be clear from my initial issue description.
I am looking for a way to push a named route with arguments (let's say ID in a Master <-> Detail transition) via
Navigatoror Nav 2.0. When I push a detail view it should automatically pick up the correct item in the master view and animate it, and also the reverse when popping the detail.Especially with Nav 2.0 this gets even more important, everything is declarative but the
OpenContainertransition has to be started imperatively.AbdallahR99 commentedon Sep 2, 2021
useRootNavigator is not working with navigator 2.0
ric-sapasap commentedon Oct 26, 2021
I managed to make this work in Nav 1.0 with this setup:
Then in TaskDetailScreen:
kuhnroyal commentedon Oct 26, 2021
That's not a named route.
ric-sapasap commentedon Oct 26, 2021
Apologies, I didn't mean to say I found a solution for the named routes issue. Just gave an example for the usage of route settings.
ValentinVignal commentedon Jan 20, 2023
Should this issue be closed since flutter/packages#240 is merged?
alefwd commentedon Jul 6, 2023
This can be closed, the fix works
github-actions commentedon Jul 20, 2023
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.