In Android a user can decide between two navigation modes:
- Gesture navigation > no system navigation bar will be shown, and any back swipe will trigger
onWillPop
- Button navigation (with 2/3 buttons) > the system navigation bar will be shown, and only the back button will trigger
onWillPop
(there is no longer a back swipe detection)
In my application, whenever one of those two methods is used to 'go back', I'm trying to determine where the onWillPop
callback came from: was it a back button press what triggered it, or was it a back swipe? I need this info in order to allow the user to perform certain actions in the app (the details are irrelevant to the question, but I basically need to decide whether to open a drawer or trigger a webview back navigation).
I haven't been able to obtain this information directly: is there a direct way to ascertain whether the back navigation action came from?
My second option was to try to get the status of the system navigation bar (shown/hidden) whenever onWillPop
is called, so that I can guess where it came from. But I can't locate this information either. I saw I can get the kBottomNavigationBarHeight
, which is constant independent of the bar's status, or the bottom padding with MediaQuery, which doesn't seem to be realiable and probably depends on the device and the size of the SafeArea.
Is there a way to get the current status of the navigation bar, or the user's preferences?