After checking various pages and ChatGPT, I need to ask for help here. I want to have a logic that once I am logged into the app and navigate through the pages, the back button should always navigate back to the home page. I am not talking about the leading back button, that one is disabled. It is the behavior when the use is using the device back button.
On the home page I have disables the back button with:
return PopScope(
canPop: false
Now on the other pages like the profile, I want the back button to navigate to the home page. Do I need PopScope for it and if so how can I do it? I tried it, but failed hard on that 😀 The Flutter dev documentation didn’t help either. 🙁
3
Answers
You could specify a custom
leading
widget for yourAppBar
if the user is logged in.In the example below, the leading widget is an
IconButton
with anonPressed
callback that takes care of the navigation.Without using third party libraries. Try it with MaterialPageRoute
vous pouvez essaiyer d executer la route dans la methode pour navigue vers la page d accueil dans le dispose() de la page , la si l utilisateur essai de quitte la page il sera rediriger vers la page d accueil.