We've touched upon programmatic navigation in the previous two sections. However, there are many more methods to get fine-grained control of navigation within your app.

AutoRouter offers the same known push, pop and friends methods to manipulate the pages stack using the generated PageRouteInfo objects. The main four types of methods are:
  • push
  • replace
  • pop
  • navigate
Use the following navigation helpers like so
// First, get the scoped router by calling
// or using the extension

// PUSH methods
// for pushing to the top of the stack
// for pushing multiple pages into the stack
.pushAll([BooksRoute(), BookDetailsRoute()])
.popAndPushAll([BooksRoute(), BookDetailsRoute()]) 
// pushes a route and pops the underlying pages based on a predicate
.pushAndPopUntil(BooksRoute(), (route) {return shouldPop(route);})

// REPLACE methods
// for replacing the last page in the stack (throws an error if the stack is empty)
// for replacing multiple pages into the stack
.replaceAll([BooksRoute(), BookDetailsRoute()]) 

// POP methods
// for popping last page of the current stack (unless the stack only has one entry)
.popAndPushAll([BooksRoute(), BookDetailsRoute()])
// pops until a specific page based on a predicate
.popUntil((route) {return shouldPop(route);})

// NAVIGATE methods
// if the route already exists in the stack, it will pop until the
// specified route. Otherwise, if the route doesn't exist in the stack,
// then add it to the stack
// The navigate method is especially good for web apps
.navigateAll([BooksRoute(), BookDetailsRoute()])
Want to have more streamlined code? Use the built-in context extension methods