Clearly Explained Flutter BlocProvider and RepositoryProvider www.dbestech.c... Production ready Bloc e-eommerce app with clean architecture • Flutter Production Rea... Latest about this app is here www.dbestech.c...
Thanks a lot. I understood. However, can you please, while recording your videos, increase your audio level. I just could not hear you clearly. I had to increase the volume to 80%. thanks a lot.
thanks for good videos , but i still confuse what is the main function of RepositoryProvider? what the difference between RepositoryProvider and blocprovider ?
Hi, great explanation! thks! I am using flutter_bloc, but no provider widgets at all. I use get_it to create and register all the instances and pass it to the bloc argument on the BlocBuilder and BlocListener. This way I am widget and context independent, which helps especially when routing. Still, you have to manage the closing of the bloc stream yourself, which otherwise is handled for you through the providers. what do you think of tis approach? thks👍
"Thanks for the video. However, I'm still a bit confused about the practical use of RepositoryProvider. Could someone help clarify whether I understood it correctly or not? Suppose I want to use flutter_bloc in a weather app. When the user triggers an event to get the weather for a particular location, my understanding is that instead of fetching data directly from the API within the bloc class, we would trigger (or call) a method from our repository class. Based on the result obtained, we'll then update the state. Is this the correct usage of RepositoryProvider in this scenario? Any insights would be greatly appreciated!"
Well, first of all we need to know why we used a repository. Using a repository in software architecture helps separate concerns by defining how data is fetched from remote or local sources within the data layer, rather than directly from the bloc. We could create a repository's instance inside the bloc but this will create another dependency between the bloc and the repository, so we inject the repository through the constructor of the bloc. Instead of creating multiple instances or using a third-party library like get_it, we can use RepositoryProvider to instantiate the repository once and pass it through the context, allowing the repository to be accessed when needed.
It's so hard to understand all the multitude of patterns used in a simple app. Maybe that's why it's so difficult for Flutter to take its seat. I looked for so long for an updated tutorial that encompassed: fetch data from external source (firebase is a good one, or any api), have it stored locally, and relay this data on to widgets. I've only seen parts of this and it's not manageable. Some tutorials teach bloc, others providers, some simple widgets, some local storage and some Dio, but not one of them employ the full solution. :(