Navigate Deep in your app — 1[Flutter tutorial]

  • If you have trouble visualising stacks, just assume a stack of books.
  • In a stack of books, you can only see the top book.
  • If you want to access any other book, you would first need to remove the books on top of it.
  • The bottom-most book in the stack was put first and can only be removed at the last after all books on top of it have been removed.
  • PUSH Operation
  • Push operation refers to inserting an element in the stack. Since there’s only one position at which the new element can be inserted — Top of the stack, the new element is inserted at the top of the stack.
  • POP Operation
  • Pop operation refers to the removal of an element. Again, since we only have access to the element at the top of the stack, there’s only one element that we can remove. We just remove the top of the stack.

Usage of function provided in Navigator

  1. Using Navigator.push()
  • Push the given route onto the navigator, and then remove all the previous routes until the predicate returns true.
  • The predicate may be applied to the same route more than once if Route.willHandlePopInternally is true.
  • To remove routes until a route with a certain name, use the RoutePredicate returned from ModalRoute.withName.
  • Calls pop repeatedly on the navigator that most tightly encloses the given context until the predicate returns true.
  • The predicate may be applied to the same route more than once if Route.willHandlePopInternally is true.
  • To pop until a route with a certain name, use the RoutePredicate returned from ModalRoute.withName. The routes are closed with null as their return value.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vivek Yadav

Vivek Yadav

Writer , Speaker, Instructor and Flutter Dev