Answer the question
In order to leave comments, you need to log in
How to correctly pass data between classes using Provider?
I use Dart\Flutter with the Provider library.
As I understand from the documentation, Provider is needed if you want to transfer data between widgets. But in my case, I want to make several classes separate from widgets and do data processing there.
The problem is that standalone classes do not have access to context. How to be in that case?
Answer the question
In order to leave comments, you need to log in
Unsure, but possible:
If the processing is done before the widget is built - as an option, try to create a parent widget, pass its context to the child class with widgets but under a different name - widgetContext. In the child class of widgets, use the necessary methods of other classes by passing widgetContext to them
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question