Luthermilla Ecole
Luthermilla Ecole

Reputation: 786

Back button linked to previous Flutter

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.

Upvotes: 1

Views: 175

Answers (1)

Khalil LAABOUDI
Khalil LAABOUDI

Reputation: 254

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);

Upvotes: 1

Related Questions