6

I have a nested structure, something like this:

List<Areas>
|-- List<Topics>
|   |-- List<Exercises>

This is the workflow of my app:

  1. App is opened
  2. Fetch API and display a list of Areas
  3. The user chooses an Area and go to next screen
  4. Fetch API and display a List of Topics
  5. The user chooses a Topic and go to next screen
  6. Fetch API and display a List of Exercises
  7. User needs to complete all of them

I started using BloC but I'm not sure if I should use a Bloc for each type of data (so one bloc for Areas, another for Topics and another for Exercises) or handle the whole structure in only one Bloc.

I see a problem having a State that contains the whole structure and needs to be updated every time a nested list is fetched from the API. Maybe this will cause memory problems?

On the other hand, having one Bloc per type of data will make complicated the communication between them.

I'm also opened to switch to another state management technique if it makes more sense.

Any help would be appreciated.

Thanks a lot.

Ale
  • 2,282
  • 5
  • 38
  • 67

1 Answers1

0

The best practice is to have one bloc per screen. So in your case it would be best to have 3 blocs. You should also keep communication between blocs to a minimum as each should have its own responsibilities.

Hadi Hassan
  • 331
  • 1
  • 3