I have a .Net MAUI application with Page A and Page B.
I want to move from Page A >>> Page B.
When I move using the following code, I have a back button (which is the desired behavior in my case) :
await Navigation.PushAsync(new MyPage());
However if I move to the other page using the following code, I don't have a back button :
await Shell.Current.GoToAsync("//MyPage");
For some other reasons I need to use navigation through Shell.
Does anyone know why I don't have a back button when navigating using Shell please ?
Thanks.
Here is the answer :
Instead of
await Shell.Current.GoToAsync("//MyPage");
I should do
await Shell.Current.GoToAsync("/MyPage");
Reason :
According to the official documentation here :
route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will be pushed to the navigation stack.
/route : The route hierarchy will be searched from the specified route, downwards from the current position. The matching page will be pushed to the navigation stack.
//route : The route hierarchy will be searched for the specified route, upwards from the current position. The matching page will replace the navigation stack.
///route : The route hierarchy will be searched for the specified route, downwards from the current position. The matching page will replace the navigation stack.
Related
If you have ever developed iOS app, you will know the dismiss(animated:) makes the UINavigationController move out of the screen from below, and it takes its child controllers together. I don't know how to implement it in Flutter:
Page A jump to page B with transition down to up, page B jump to page C with default transition right to left. Now I don't know how to go back to page A with transition up to down.
Use navigator.pushAndRemoveUntil to navigate to A. This would remove B and C.
From the documentation, pushAndRemoveUntil is used to:
Push the given route onto the navigator, and then remove all the
previous routes until the predicate returns true.
The problem is not being able to initialize a navigator with a navigation history.
I have a work around but cannot seem to match the normal pop and push animations. It is a subtle difference, but stands out when the rest of the navigation animations work the standard way and then this one screen is custom.
Desired: Popping a route moves off screen to the right 'staying on top' and the previous/parent screen slides in slightly from the left 'behind the popped one'.
I've got over 400 leaf nodes to pick from. Values come in the form: A/B/C it mimics a folder structure.
The issue is my value picking screen must be able to open up deep into the hierarchy and has no history to pop back to.
I've tried pushing the stack history before the target to get the history 'primed' but this results in unwanted navigation animation. The screen must open up on the chosen values folder/screen.
I've recreated the setup in dartpad here:
https://dartpad.dartlang.org/?id=0f3a3fd815c1754c964c4e7f5a872052
Thanks in advance.
I am facing a very weird issue on my code. I have 4 bottom tabs on my app. Say btm_tab1, btm_tab2, btm_tab3 and btm_tab4.
Each bottom tab has its own Nav graph. Say graph_1, graph_2, graph_3 and graph_4 respectively for each of the bottom tab. And there is a common graph say common_graph which is included in all of the four bottom tab's nav graph.
Common graph contains 3 destination and one of the destination has a deeplink on it.
When i open this deeplink it redirects me to the correct destination but when i press back from the destination it goes back to each of the bottom tab with that destination opened. I know it is common as per offical docs but this is requirement of use case and i don't want to add single destination/fragment in each of the bottom tab graphs.
So, anyone know how to solve this problem?
There are 3 screens in my app. When I use popAndPushNamed() in the 2nd page, it pops the 2nd page and shows the 3rd page, but when It pops it shows the 1st page behind it in milliseconds. how to avoid that?
is Animation the way?
or are there any other methods just like push and show 3rd page, and pop 2nd page when the 3rd page visible to the user?
popAndPushNamed() as the documentation suggests, pushes the new route but pops the old route simultaneously, and hence, there is a small moment where you can see the first page even if your new routes are fully opaque. Replace the method with Navigator.of(context).pushReplacementNamed() and it should work as expected.
My app has three tabs:
Tab1
Tab2
Tab3
On Tab2, the user has progressed an order to completion. At this point, I want to clear the navigation stack for Tab2, and I want to navigate the user to a page that normally sits under Tab3.
Currently, this is what I've got:
this.navCtrl.popToRoot();
this.navCtrl.parent.select(TabsPage.Tab3);
this.navCtrl.push(OrderStatusPage);
Where TabsPage.Tab3 is the index of Tab3.
The reason I am popping to root is an attempt to clear the pages in the navigation stack so that when the user returns to this tab later, I want them to go back to the root page of that stack.
Then, I followed Ionic's Tab documentation which suggested I could change tab by calling this.navCtrl.parent.select.
Finally, I'm then trying to push the OrderStatusPage onto the stack.
Here's what happens when I run it:
When the application pops to root, it does appear to clear the navigation stack, but in the console I can see that it hits my logon page, which isn't on the Tabs navigation stack, so I don't understand how that happens. I also don't like how it navigates to root. Isn't there some way just to clear the stack without moving the user away from the page?
The page then successfully navigates to my Tab3 page, but the command to push the OrderStatusPage onto the stack doesn't seem to register.
Any ideas?
Each tab has its own navCtrl, so when you switch to Tab3, you need to push OrderStatusPage into Tab3's navCtrl, but you seem to be using the same this.navCtrl.
For Question 2, You don't see this.navCtrl.push(OrderStatusPage) result because you switched to tab3, but are still pushing into tab2's navCtrl!
For Question 1, you don't mention your complete page structure, but I'm guessing your three tab pages are shown on top of your login page.
You can put each tab page's navCtrl into a service or a global variable like the method that is discussed here (under: Pushing each tab page into the stack), and then push/pop into them using that service.
Also, as a side note, in case you are taking the user from one step to another step, you can also use ionic slides instead of tabs.
The closest I've come to a solution here was to add the following line of code after selecting the AccountTab:
this.navCtrl.parent.select(TabsPage.AccountTab);
setTimeout(() => {this.navCtrl.parent.getSelected().push(OrderStatusPage)}, 100);
It's not at all a good solution but hey it works.