1

I have a provider for which I use a ChangeNotifier with notifyListeners() so the UI updates with the changes.

This is a bit different because I don't need to update the UI, at least not in the same view. Example: In page A I change the value of my global var and in page B (I need to move from one page to another) I show my var.

So I have something like this:

class MyGlobalClass {
  String test = "";

  changeTest() {
    test = "New";
  }
}

final myGlobalClass = MyGlobalClass();

The problem comes more from the value than the UI. The value still not updated when I inspect the object.

Am I force to use always a provider for these cases and pass the context? Because I also need to modify some global vars in the beginning where I don't have any context yet.

isn't this the same approach? https://stackoverflow.com/a/29182641/4858133

Dani
  • 3,128
  • 2
  • 43
  • 91

1 Answers1

0

I only needed to make the global var static

Dani
  • 3,128
  • 2
  • 43
  • 91