slovnicki / beamer

A routing package built on top of Router and Navigator's pages API, supporting arbitrary nested navigation, guards and more.
MIT License
589 stars 130 forks source link

Clear all beamer history #617

Closed dri94 closed 1 year ago

dri94 commented 1 year ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] How can I clear the full stack history in beamer? This might be already documented or a feature however I seem to be overlooking it.

Describe the solution you'd like Basically, I want to navigate to a new screen and remove everything from the backstack.

Describe alternatives you've considered I've tried making a loop to do this like

      HistoryElement? element = _beamer!.removeLastHistoryElement();
      while (element != null) {
        element = _beamer!.removeFirstHistoryElement();
      }
      _beamer!.beamingHistory.clear();

Additional context Add any other context or screenshots about the feature request here.

slovnicki commented 1 year ago

Hey @dri94 :wave: Thanks for creating an issue.

From what you describe, I believe you would like to do Beamer.of(context).beamToNamed('...', stacked: false) or redefine your BeamLocation.buildPages if you're using that API.

The history that you are mentioning above is purely for the history of beaming, i.e. the history of what routes you supplied to the BeamTo* functions over time, which is not the same as the current stack of pages (that I understand you want to clear)

Let me know if this helps.

dri94 commented 1 year ago

Thank you!