0

I read docs, and looked a lot of examples, but still can't understand should I use Provider if I need access to data in several classes. The main problem -- context that do not exists outside widgets.

So probably I do not understand conception of Provider? Here small example what I mean:

class A
{
String foo;
}

and

class B
{
 String x;
 Provider<A>.of(context).foo = "aaa";
}

I faced with this problem and I do not know how to resolve it.

Dmitry Bubnenkov
  • 9,415
  • 19
  • 85
  • 145

1 Answers1

0

I faced the same problem and i found the solution in this package get_it , you can access the instance of the class without using provider and you don't need context, however provider is used to link between your business logic and the UI , so you should use provider.of(context) in the ui not in your logic, but i think this package will help you

kaarimtareek
  • 451
  • 3
  • 10