I’ve implemented Navigator 2.0 navigation in my Flutter web app.
Suppose that I navigate through the app (which is a simple CRUD app for managing pets), such that I have a list of pages and browser history are as follows:
Pages: [/home, /pets, /add-pet]
History: [/home, /pets, /add-pet]
Once I have added my pet and pressed ‘Save’ I automatically navigate back to the /pets list, so pages and history now looks like:
Pages: [/home, /pets]
History: [/home, /pets, /add-pet, /pets]
So now I am on the /pets page and I decide that I want to press back on the browser to go to /home, but I press back and I go to /add-pet instead, because that’s what’s in the history.
How am I supposed to automatically (without pressing the back button) navigate back from /add-pet to /pets such that the browser history represents that and removes /add-pet from the history?