I'm trying to implement Clean Architecture in my flutter app. There is a module named Purchase Order in my app. This contains List Screen, Filter Screen, Add Purchase Order Screen.
Currently, I have one controller (GetxController) for all of them. All of the business logic for all of those screens is included in that controller. The reason for not having separate controllers is the dependency on these screens on each other.
Let's say the user applies filters from Filter Screen, which should update the List Screen. Likewise, the user can remove filters and change some filter values from the List Screen.
Likewise, if the user adds a new Purchase Order, that should update the List Screen with the newly added Purchase Order
How to achieve the communication between multiple controllers in accordance with the clean architecture.
Hope you are fine I believe the issue here is a state management issue, not a clean architecture issue.
I would approach it in 2 different ways:
1-Same controller with
copyWithstate: you can have one controller and 3 listeners on each screen the state should hold the 3 screens state -> also it should implementcopyWithfunctioncopyWithcreates a new instance of the state with previous data in case you want to modify a parameter and keep the other ones therefore whenever you want to update a screen, all screens will be updated.2- Controllers and listners the second one is having a separate controller for each screen, and a listener on the constructor of each one, whenever a controller has changes the others will be notified.