In the “Popping the Stack” section, if one has a StatefulWidget one could add setState code to the the IconButton onPressed to reset variables and such. This works great, but is there a way to do this with the “<” (back) button?
I’m not that well versed in Flutter internals, but if you’re talking about the general back button on Android or iOS, you could always override the default navigation, by adding your own leading element for the back button.
Other than that, you could pass in the ‘onWillPop’ callback, which notifies you when a widget is about to be popped. In that case, you could reset the state before popping, and then return ‘true’, to allow the Widget to be popped!
Thanks @filbabic. I came up with a solution which works, but not sure if it is the best solution. I’ll take a look at the onWilllPop callback as it might be better than what I did. I’m still learning.