0

If I have many actions in my app like

( get popular movies, get trending movies , get new movies , get top rated movies)

each one represent single screen with it's own state

should I use one bloc for all actions

or have one bloc per action ?

all these actions return the same model with different data , how can I even return different data in same bloc for different actions ?

goo add01
  • 1
  • 1
  • I'm not that much familiar with bloc, but I used single bloc/cubit per action. I just follow the example of [doc](https://bloclibrary.dev/#/) – Md. Yeasin Sheikh Oct 14 '21 at 20:54

1 Answers1

0

As mentioned by @YeasinSheikh I suggest you to go through the documentation. It is one of the best documentation I have ever seen.

Regarding your scenario (Suggestions not rule):

  1. Create 1 bloc per feature.
  2. If you are using different screens for popular, top rated etc., use separate blocs as you may not want state of popular screen changing when user goes to top rated screen.
  3. If you are using same screen for popular, top rated etc, you can use 1 bloc with state based on filters.
  4. State or events can have multiple properties. You can always use a state or event property to define filter option.eg: LoadedMovies(listOfMovies, MovieEnum.Popular)

If you are stuck, show us what you tried and community will be able to support you.

singhnikhil
  • 670
  • 5
  • 7