nubank / nuvigator

A powerful routing abstraction over Flutter Navigator, with nested Navigator and Deeplinks
Apache License 2.0
275 stars 33 forks source link

Perform a SystemNavigator.pop() when trying to pop the root screen #26

Closed rafaelring closed 4 years ago

rafaelring commented 4 years ago

Sometimes we may have as a root screen on Flutter a screen that is "closeable" - eg. when we launch a Flutter flow from a Native screen, the root screen on Flutter will usually be something the has a close or back to return back to the previous screen as the behaviour is much more of a "push" than a "replace". In these scenarios, trying to call a Nuvigator.pop() on this screen will fail as it's not poppable. At the same time, even when launching a full Flutter app, the root screen is something that might have a close button or behaviour and the pop() will also not work. But this is a behaviour that should by default happen as pressing the physical back button will pop this activity anyway. So, this commit implements this behavior on the pop() method: if trying to call pop() on the rootNavigator when the stack is empty it'll perform a SystemNavigator.pop() and kill the screen.