Mohd Azwan
Mohd Azwan

Reputation: 101

how to go back 2 page before in flutter

Right now I am trying to delete data and when I am done delete it. It should be going to the homepage. The issue here is when I am using the navigator to the homepage. The user_id returns null instead of it should be showing the real user_id. How can I manage the flow of content?

Code that I use to go back 2 pages before.

 new RaisedButton(
      child: new Text("OK DELETE!",style: TextStyle(color: Colors.black),),
      color: Colors.red,
      onPressed: (){
        deleteData();
        Navigator.of(context).push(
          MaterialPageRoute(
              builder: (BuildContext context)=> OwnerPage())
        );
      },
    ),

The image on before deleting occur:

enter image description here

The image on after deleting occur:

enter image description here

For additional information. From the login page to the home page, I am using this type of code: enter image description here

Upvotes: 2

Views: 2102

Answers (2)

biniyam112
biniyam112

Reputation: 1182

If you are using routes to navigate between pages you can do this

Navigator.pushNamed(context,'/OwnerPage');

this will directly navigate to the OwnerPage

Hope this is helpful!

Upvotes: 2

Akif
Akif

Reputation: 7640

There are different approaches to navigate between pages. The bad one is, you can Navigator.pop() two times. The good one is, you need to add parameters:

  Navigator.of(context).push(
      MaterialPageRoute(
          builder: (BuildContext context)=> OwnerPage(username: username, user_id: user_id)) // Add parameters
    );

Upvotes: 2

Related Questions