1

I want to know how can I link a page to previous, instead of choosing an only path, because sometimes there is other paths to the same page.

 Navigator.pop(context);

Haven't worked for me, I only get a black screen.

Luthermilla Ecole
  • 666
  • 1
  • 6
  • 14

1 Answers1

1

it depends on the way how you opened the page;

open new screen:

// Within the First Page widget

  Navigator.push(
    context,
    MaterialPageRoute(builder: (context) => SecondPage()),
  );

now you can return to the first page using Navigator.pop() like that :

// Within the Second Page widget

  Navigator.pop(context);
Khalil LAABOUDI
  • 244
  • 1
  • 2
  • 12
  • You are very right, thank you. The only issue is that it adds a back button on the back screen where it didn't have any button before. – Luthermilla Ecole Nov 05 '20 at 21:19
  • 1
    you can customize the app bar as you want , You can remove the back button by passing an empty new Container() as the leading argument to your AppBar. check this out it has answer of your issue : https://stackoverflow.com/questions/44978216/flutter-remove-back-button-on-appbar – Khalil LAABOUDI Nov 05 '20 at 21:23
  • Thank you again, you're a great help – Luthermilla Ecole Nov 05 '20 at 21:34