Home > database >  Flutter navigator doesn't show back button on App bar
Flutter navigator doesn't show back button on App bar

Time:04-17

I'm new to flutter and I'm Having a problem with Navigator , I don't know why it doesn't show back button on the next page (i want to show a back button on the next page app bar) when I use Navigator.push even though I have seen a lot of videos that show the opposite, maybe someone will have the answer here

here's the code I'm Using:

enter image description here enter image description here

CodePudding user response:

In the appbar there is leading property...

In that leading property you can use any Widget. As your requirement you can use icon Widget to navigate

CodePudding user response:

You have to code the back button in "HomePage" class. In Flutter, when you navigate from page A to page B, the page B will be above page B, something like a stack, but page A and B have to be build on their owns.

A solution that might resolve your problem is to use this code in "HomePage"

  return Scaffold(
      appBar: AppBar(
        title: const Text('Home Page'),
      ),
      body: Center(
          child: ElevatedButton(
                 child: Text('Back Button'),
                 onPressed: (){
                   Navigator.pop();
                   },
                ),
          ),
    );
  • Related