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 129 forks source link

Widget for intercepting `beamBack` #505

Open matuella opened 2 years ago

matuella commented 2 years ago

Is your feature request related to a problem? Please describe. Currently, if I use BeamerBackButtonDispatcher with alwaysBeamBack, I have no way to intercept (and possibly block/veto) navigations that comes from .beamBack.

Describe the solution you'd like We could have a widget that does similar to WillPopScope but that also handles beam backs, i.e: BeamerWillPopScope, or even a completely independent widget that only observers beam backs, i.e. WillBeamBackScope.

slovnicki commented 2 years ago

Hey @matuella

That's a very good suggestion! There's a third option too; we can treat this with a similar callback as onPopPage.

dsyrstad commented 2 years ago

I'd like to conditionally stop navigation altogether - not just beamBack. Imagine you're on a form, fields have been modified, and you have a drawer which allows navigation elsewhere in the app. If I tap an item in the drawer, I want to check if the form is modified and prompt the user prior to continuing navigation. This seems to be an overlooked feature in Navigator 2.0 in general. It seems like you have to roll your own solution.