Hello if I want to use Provider.of... in multiples routes, the Provider widget must be a parent of material app? Or I can create de Provider widget in any route(no material app widget) and routes pushed by this widget can use Provider.of... ?
Thanks
To workaround this I pass the context of the route where you provide your dependencies to the new route widget arguments, and to get the dependency I pass the parent context.
I'm not sure if this is a good practice though :)
Eager to know the right solution too.
The general rule is, if two widgets wants to access the same provider, the provider must be a common ancestor of both widgets.
This is true for anything, including routes.
So yes, above add your provider above MaterialApp (or its equivalent)
Most helpful comment
The general rule is, if two widgets wants to access the same provider, the provider must be a common ancestor of both widgets.
This is true for anything, including routes.
So yes, above add your provider above
MaterialApp(or its equivalent)