Understanding the principles of moving along routes in Flutter

Issue

I have routes:

'/home'
'/home/nav_one'
'/home/nav_one/nav_two'
'/home/contacts'
'/home/contacts/description'

and the transitions were made:

'/home' -> '/home/nav_one' -> '/home/nav_one/nav_two' -> '/home/contacts/description'

Where will the command return: Navigator.pop():
To '/home/nav_one/nav_two' or '/home/contacts'?

If in the first option, then why do we write these same routes, for the sake of ease of reading and understanding?

Solution

Assuming that these are the route names and that you’ve been Navigator.pushNamed()ing the screens the answer is,

To '/home/nav_one/nav_two'

These route names are just identifiers so you can name them like,

'/home'
'/nav_one'
'/nav_two'
'/contacts'
'/description'

for your own convenience.

Answered By – happy_san

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *