I want to make multiple routes share the same provider but the only way that I figured out is to wrap those routes inside a nested navigator and the provider is at the top of the nested navigator
any other ways to do such thing
I want to make multiple routes share the same provider but the only way that I figured out is to wrap those routes inside a nested navigator and the provider is at the top of the nested navigator
any other ways to do such thing
It is common practice to put the Provider at the very top of the widget tree. For instance, in the provider example, it sits inside the runApp() call.
You can pass what is being shared to the new route and to a new Provider widget which can provide it to that route's widget tree. So, you could have a single instance of a bloc class for example accessible to multiple routes, but still only instantiate that bloc once.