Babofett
Babofett

Reputation: 192

Root route and different initialRoute creates strange WidgetTree

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.

enter image description here

The widget tree seems to load the root-route as well. But why?

enter image description here

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.

Upvotes: 1

Views: 179

Answers (1)

magicleon94
magicleon94

Reputation: 5182

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.

Upvotes: 1

Related Questions