hello i want to ask what’s better to structured bloc, in my case i have screen to show all jobs, favorite the job and the other screen can create job. Should i create only one bloc or separate bloc for create job, show the job, see job details. I haven’t create the bloc since im stil thinking where to put the bloc and how the bloc looks like
2
Answers
See whether to use a single or multiple BLoCs depends on the complexity and relationships between the features.
If your features (showing all jobs, favoriting jobs, and creating jobs) are closely related and share a significant amount of logic, a single BLoC might make sense for simplicity. However, if each feature has distinct logic, consider separate BLoCs for better maintainability and organization.
Here’s my suggestion:
Home Screen BLoC: Manages the logic for fetching and displaying all jobs.
Favorite Screen BLoC: Handles logic related to favoriting and unfavorite jobs.
Create Job BLoC: Manages the logic for creating new jobs.
This way, each BLoC is focused on its specific functionality, promoting a cleaner and more modular codebase. It also makes it easier to test and maintain the code as your application grows.
I use A repository approach where every widget will have its own controller and state check this
[Blanket App]
App Architecture image
https://github.com/farooq958/Blankets_App/assets/41532119/eade1a38-c073-461f-9569-827d937b4f83