Flutter provider: Looking up a deactivated widget's ancestor is unsafe

Viewed 10

I have a class which triggers some functions from my provider:

...
Provider.of<MyRents>(context, listen: false).something();
...

The exception I get is:

Looking up a deactivated widget's ancestor is unsafe.
E/flutter (24312): At this point the state of the widget's element tree is no longer stable.

This is an initial check that needs to be done in a class and it modifies the provider updating it with some values for the tree later. I understand the context can change and it can be unavailable, but how could I fix it? Calling my class method and separately, when it's done, calling the provider?

0 Answers
Related