I'm practicing the new API, navigation 2.0, for my web project with flutter. I'm quite new to flutter either.
I successfully implemented the routing with navigation 2.0, but still can't figure out how the onPopPage works. If I tapped the button to navigate to the sub-page, the back button is automatically generated in the header. So when I clicked the back button in the header, it takes me home.
What if I implement another nested sub-page of the sub page, then I clicked the back button it takes me all the way to the top page, home.
I think it's because of the onPopPage function which I added like this. How can I edit this function to work properly. I want the back button to pop the only recent page of navigation history.
onPopPage: (route, result) { if (!route.didPop(result)) { return false; } _currentPath = 'home'; show404 = false; notifyListeners(); return true; }, https://stackoverflow.com/questions/66728990/how-can-i-go-back-to-recent-page-of-history-with-onpoppage-in-navigation-2-0 March 21, 2021 at 12:58PM
没有评论:
发表评论