Complete the code to navigate to SecondPage when the button is pressed.
ElevatedButton(
onPressed: () {
Navigator.[1](context, MaterialPageRoute(builder: (context) => SecondPage()));
},
child: Text('Go to Second Page'),
)Navigator.push adds a new page on top of the current one, allowing navigation forward.
Complete the code to go back to the previous page when the button is pressed.
ElevatedButton(
onPressed: () {
Navigator.[1](context);
},
child: Text('Go Back'),
)Navigator.pop removes the current page and returns to the previous one.
Fix the error in the code to navigate to ThirdPage correctly.
Navigator.push(context, [1](builder: (context) => ThirdPage()));MaterialPageRoute is the standard route for material design pages in Flutter.
Fill both blanks to navigate to FourthPage and then remove the current page from the stack.
Navigator.[1](context, MaterialPageRoute(builder: (context) => FourthPage())); // This removes the previous page Navigator.[2](context);
pushReplacement adds a new page and removes the current one. pop removes the top page from the stack.
Fill all three blanks to navigate to FifthPage, pass data, and then pop back with a result.
final result = await Navigator.[1](context, MaterialPageRoute(builder: (context) => FifthPage(data: [2]))); Navigator.[3](context, result);
push navigates to a new page and waits for a result. Data is passed as an argument. pop returns to the previous page with the result.