As the app grows bigger I found myself need to access other bloc's state and data in another bloc more often, and usually their in different route. So I wonder is there any reason to not place all blocs above the MaterialApp widget?
It is fine. You can put it anywhere in the widget tree you want. I do that when I use bloc for dynamic theming or localization, which both are needed in the MaterialApp widget to rebuild it with different them or localization when changed.
Hi @QAQyzk 馃憢
Thanks for opening an issue!
The downsides to providing all blocs globally include:
reset events because blocs are never closed (developer experience)and more.
I would highly recommend scoping blocs to the subtrees that need them and you can use nested Navigators when you want to make a bloc available across multiple routes or use BlocProvider.value to provide an existing bloc to a new route.
I highly recommend checking out the bloc access recipe and https://youtu.be/laqnY0NjU3M for more information.
Hope that helps 馃憤
Thanks! Those information is really helpful! I will keep blocs as scoped as possible. :+1: