I'm making a chat app and i want to send push notifications to an user only if he is not in the chat screen, so i need to know the current screen or path
I tried saving in state the name of the screen each time he enter to it, but of course it did´nt work when user go back with Navigator.pop or if he uses gestures
I don't know what is the right way to do it
Maybe you can use the
disposemethod to update the state whenever the user leaves the screen:The
initStatemethod is called when the widget is created, and thedisposemethod is called when the widget is removed from the widget tree,disposeis typically called when the user navigates away from the screen.