0

My app depends (at least partially) on outside state (from the filesystem or settings). It's not that the user will update state on his own, it's just that when the app sets certain variable, it saves them to disk and when it's loaded, it reads them from disk.

As long as I don't navigate, everything works well (meaning that when I set state it is saved and when I restart the app the variables get restored). The problem is navigation - If I navigate a few screens in, change state, and then pop back a few screens, and state won't update.

This is expected, as popping should return the screen back to where it was before.

But the problem is that unless I manually restore settings at every setState, that variable isn't ever updated.

Is there a way to have pop run a function (or method) to update certain variables on pop?

If I don't pop it's not a problem, as when I change state on the filesystem I c

Charles Shiller
  • 1,013
  • 4
  • 13
  • 32
  • possible duplicate of https://stackoverflow.com/questions/48582963/flutter-how-to-execute-when-clicking-back-button/48597815#48597815 – Shady Aziza Mar 23 '18 at 04:06
  • @aziza _almost_. But there it (um. You :) ) answer about intercepting a click on the back button on the AppBar. What about the back button on the phone? – Charles Shiller Mar 23 '18 at 04:41
  • this is already included in the answer (nav==true||nav==null), does not this work for you ? – Shady Aziza Mar 23 '18 at 08:00
  • check this too http://cogitas.net/know-user-tapped-back-button-back-navigation-arrow-flutter/ – Shady Aziza Mar 23 '18 at 08:02

0 Answers0