I am going to build flutter app with Getx.
I followed nested navigator from
https://github.com/jonataslaw/getx/issues/799#issuecomment-730719165
at this example, only shows 1 step sub routes like "/browse".
I need to make another sub routes like "/browse/tabX" and "/browse/tabY"
when click browse button from BottomNavigationBar, It shows tabs (tabX and tabY) on the top. and tabX is default selected.
for the body, it shows automatically their pages.
Also using Get.Named('/browse/tabY') can access to open their page(select second tab and show their body).
Can you help me?
Oh Now I got the answer!
What I make a mistake is I did not use "sub-name".
for example, at initialRoute,
I used '/home/browser' but it should be '/browser' if it is sub-route.
Because the concept is route to subrouter's root and handle by subrouter.
so "initialRoute from root" route to /home first.
and "initialRoute from subroute" route to /browser again!
I use classed variable instead just string so I did not figure this difference out.
Related
I am building a flutter app. I have a place in the app where you can make infinite loops with
GoRouter.of(context).push(...);
I mean you can navigate to Screen A and then to B and then to A. There are many screens and many possible loops but I want to protect the user from the most obvious one, the A>B>A>B type.
(I don't care about greater loops like A>B>C>A>B>C and alikes)
To do that, I want to check the navigation stack top element and if the element is the same where we would go with a push, I would do a pop.
Problem is that I can't find anything on Google...
Tried:
Googling it, checking API docs, reading IntelliSense
EDIT:
There is a big set of screens and can't know the previous location solely based on the current one.
Use GoRouter.of(context).location
GoRouter.of(context).location gives you the current location
Example:
Route A has route path /routeA
Route B has route path /routeB
GoRouter.of(context).location will return either /routeA or /routeB
Based on which you can make decision to pop() or push() page
First: forgive me if it's a dumb question, but I'm trying to figure out step by step how Navigator 2.0 works and how to implement it in my app; this seems to be the only piece left of this puzzle but I weren't able to find an answer anywhere.
I've followed this Medium article on how to implement the new Navigator inside my Flutter app but I don't get how to use it after I've finished.
I mean: I have replaced MaterialApp with MaterialApp.router, specifying the custom RouterDelegate and the custom RouteInformationParser I've created, but how can I switch from the '/home' route to the '/profile' one after I pressed a button?
With the old navigator I would have added a Navigator.of(context).pushNamed('/profile) in the onPressed function of the button in the home screen, is it still valid or now should I proceed different?
For navigator 1.0:
Navigator.of(context).pushNamed('/profile');
For navigator 2.0 (using go_router package):
GoRouter.of(context).pushNamed('/profile');
I'm trying to navigate between different screens using named routes.
I'm defining a root-Route (you may call it fallback route(?)), some other routes and an initialRoute, linking to a different screen than the root-Route.
The widget tree seems to load the root-route as well. But why?
TicketsScreen has many Widgets and I don't want them to be loaded beforehand.
BTW: This is only an example. When having multiple routes, it still loads both of the mentioned.
That's because /tasks has a leading /.
The navigation system pushes everything that's there, let me explain.
If you had there routes:
/
/tasks
/tasks/new
navigating to /tasks/new will push all of three.
If you want to keep "single" routes, you should use top level qualifiers. In your case that would be removing the / from /tasks.
This mechanism is useful to push a path and avoid strange pops if, for example,
you navigate to /tasks/new from a shortcut (not from /tasks) and then pop back. Would it be good to pop to the starting point? Would it be better if popping from a new task will lead to the tasks page?
That's a brief explanation of what the navigator tries to do, I guess.
I'm building a tabbedpanel which consists of three tabs. I have a tab with form with text fields in it. while I am navigating from this tab I'm unable to loose the state of this tab. Can anyone suggest how to get around it?
Is the Form/ around the TabbedPanel? If YES then you can override
org.apache.wicket.extensions.markup.html.tabs.TabbedPanel#newLink()
And do something like:
form.setModelObject(new EmptyObject())
Or:
form.setModelObject(null)
Or:
use a visitor to set "empty"/null model for each FormComponent in the complete form
Or:
Just in the specific tab by using the passed 'index' parameter to #newLink().
I 'm trying to build my own simple breadcrumb component that pushes a PageRefence onto a List for each and every Link in the application.
Unfortunately, setResponsePage() is final (I use wicket 6).
The only other option that comes to my mind is to add a parameter to my base page constructor. But this would require me to change every link in the app..
Are there any other options?
Since you already have a base page, it's easier to override onBeforeRender() in your base page to update the breadcrumbs list that you'd store in your Session object.
Or am I missing something?
To answer my own question:
In the end I realized, that I do not want to have the breadcrumb updated on each new page.
Therefore I created an object that holds a List of Pagereferences. When I navigate to a new Page, I take the list of the current page, make a copy of it an add the current page. The resulting list is pased onto the new page.
All this is handeld in the base page.
Keeping it in the page, avoids problems with multiple tabs / windows.
Thanks for the help.