I initially created one Cubit to manage the state of my screen, but as it became too complex, I refactored it into four separate Cubits. Now, to make the screen function as intended, I had to implement communication between these Cubits using listeners and buidlwhen, which has resulted in messy and difficult-to-read code. Is there a better way to handle this?
To illustrate, imagine a screen with four sections:
- The first three sections contain buttons or actions.
- Pressing a button or any action calls a data provider, shows different loading states, and updates other sections.
- The final section displays a list that updates based on these actions.
When the screen initially loads, there is a full-screen loading indicator. The same happens if any error occurs. After any interaction, there are different loading indicators.
Due to the nature of this screen, which results in many combinations of loading and state changes, I’ve tried implementing the strategy pattern. Do you have some examples of complex Flutter apps using BLoC? Do you have any suggestions for writing complex screens in a clean way?
I cant provide a code example, but I hope you get the idea.