Understanding navigation
Flutter has two ways of navigating between views. The first pattern introduced was an imperative API that makes use of the Navigator
widget. Think of Navigator
as a stack that sits at the top of the application. A stack is a linear data structure that follows the principle of Last In First Out (LIFO), meaning the last element inserted inside the stack is removed first. Stacks generally have two main functions: push which allows you to add a new item to the stack, and pop
, which removes the item from the stack that was added. The Navigator
widget extends this API further:
pop
: Pops the top-most route off the navigator.popAndPushNamed
: Pops the top-most route off the navigator and pushes a named route onto the navigator.popUntil
: Pops routes off the navigator until some conditions are met.Push
: Pushes a route onto the navigator.pushAndRemoveUntil
: Pushes a route onto the navigator and pops routes until some conditions are met.
...