Which method adds a new screen to the navigation stack?
push() adds a new route to the stack, making it the current screen.
Navigate between screens using Navigator
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
Flutter uses a Navigator widget that manages a stack of screens (called routes). Think of it like a stack of cards - you can push new cards on top or pop them off to go back. The Navigator keeps track of every screen you visit, so pressing the back button always returns you to the previous one.
1// Navigate to a new screen (push onto stack)2Navigator.push(3context,4MaterialPageRoute(builder: (context) => SecondScreen()),5);67// Go back to previous screen (pop from stack)8Navigator.pop(context);910// Replace current screen11Navigator.pushReplacement(12context,13MaterialPageRoute(builder: (context) => NewScreen()),14);
Below is a full example showing two screens. The first screen has a button that pushes the second screen onto the stack, and the second screen has a button that pops itself off to go back.
1class FirstScreen extends StatelessWidget {2@override3Widget build(BuildContext context) {4return Scaffold(5appBar: AppBar(title: Text('First Screen')),6body: Center(7child: ElevatedButton(8onPressed: () {9Navigator.push(10context,11MaterialPageRoute(12builder: (context) => SecondScreen(),13),14);15},16child: Text('Go to Second Screen'),17),18),19);20}21}2223class SecondScreen extends StatelessWidget {24@override25Widget build(BuildContext context) {26return Scaffold(27appBar: AppBar(title: Text('Second Screen')),28body: Center(29child: ElevatedButton(30onPressed: () {31Navigator.pop(context);32},33child: Text('Go Back'),34),35),36);37}38}
AppBar automatically shows a back button when there is a previous route to return to.
Before coding navigation, define expected user flow:
When flow is mapped first, push, pop, and replacement decisions become clear and consistent.
Navigate between screens using Navigator. Navigation manages how users move between screens and return to previous states.
Connect each concept to real app features you can build.
Design route names and arguments before wiring screen UI.
Poor routing decisions create confusing UX and fragile deep-link behavior.
push() adds a new route to the stack, making it the current screen.
pop() removes the current route and returns to the previous one.
pushReplacement removes the current route and pushes a new one, so back button won't return to the replaced screen.
MaterialPageRoute creates a platform-adaptive page transition from one screen to another.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue