B
B
beduin012019-08-12 17:37:37
Dart
beduin01, 2019-08-12 17:37:37

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

1 answer(s)
K
Korsik, 2019-10-25
@Korsik

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 question

Ask a Question

731 491 924 answers to any question