Navigator Basics
Swipe to show menu
The Navigator is a widget that manages a stack of route objects, enabling screen navigation in your Flutter app. Each time you move to a new screen, a new route is pushed onto the stack, and when you return, a route is popped off, revealing the previous screen.
To move between screens in Flutter, you use the Navigator.push and Navigator.pop methods. When you want to go to a new screen, you use Navigator.push, which adds a new route to the navigation stack. When you want to return to the previous screen, you use Navigator.pop, which removes the current route from the stack and reveals the previous one.
main.dart
Use Navigator.push when you want to move forward to a new screen, such as opening a details page from a list. Use Navigator.pop when you want to return to the previous screen, such as closing a details page and going back to the main list.
main.dart
The navigation stack keeps track of your route history, so each time you push a new screen, the previous screens remain underneath. Using Navigator.pop removes only the topmost route, allowing you to return to exactly where you left off.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat