NavController remove pages from history to improve navigation

Hello everybody,

For some time I have been looking to improve the navigation of my app by being able to control the pages people can click back to. As of recently I have discovered the NavController remove() (based on this post: function which does remove pages from the history but also navigates back to the last page available.

This is not the behavior I would like to see in my app. What I would really like to have is a way to remove a page from the history to be able to skip that page when somebody clicks “back”. This is especially convenient for pages that require the person to add or edit information. You wouldn’t want people to constantly click through those pages until they’re back at the main screen.

Does anyone have a solution to remove pages without transitioning to them?

Thank you very much in advance.

Best regards,

1 Like

I encountered the same thing and came up with this solution: