I have a flow to open the apps using navigation like this:
Profile Page(1st) -> List Attachments(2nd) -> List Resumes(3rd) -> Edit Resume(4th)
Then, from "Edit Resume(4th)" I want to go to "List Attachments(2nd)" with "remove the navigation state from 2nd 3rd 4th". So when I success navigate and open the "List Attachments(2nd)" screen, and when I click the back button from AppBar
(in the "List Attachments(2nd)" screen) or from the device (in the "List Attachments(2nd)" screen), it will not back to "Edit Resume(4th)", but will back to "Profile Page(1st)". How to do that?
I already try with this:
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => AttachmentsListPage(widget.userEntity)),
(Route<dynamic> route) => false,
);
It removes my back button on the AppBar
in the "List Attachments(2nd)".
I also try with this:
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context) => AttachmentsListPage(widget.userEntity)));
But still not working.
Fyi, I'm not using route
.
I fix this using popUntil
.
Navigator.popUntil(context, ModalRoute.withName(routeName))