Issue
I have several Page.
1. Start Page
2. Page 2
3. Page 3
4. Main Menu
From 1 -> 2. and 2 -> 3. i use this for navigation :
Navigator.of(context).push(new MaterialPageRoute<MyPage>(
builder: (BuildContext context) {
return new MyPage();
},
));
and for 3 -> 4. I want to use this (Push Replacement, will not going back), but it doesnt work and act like normal Push:
Navigator
.of(context)
.pushReplacement(new MaterialPageRoute(builder: (BuildContext context) {
return new MainMenuPage();
}));
Confusing.
Solution
I had the same problem going on, guess it was due to the fact that my screen #3 came from a dialog and i wasn't disposing of it before. So what I did was:
Navigator.of(context).popUntil((route) => route.isFirst);
then
Navigator.pushReplacement(context, MaterialPageRoute(builder: (BuildContext context) => NewPage()));
Answered By - Fernando Rocha
Answer Checked By - Mildred Charles (JavaFixing Admin)