I have completed Reso Coder tutorial about Clean Architecture with TDD in Flutter Apps. But there are two points interesting for me:
If we have global widgets like
Loading
,Failure
,Empty Case
and so on, in which layer and how we can store them to access from any feature? is it okay to create folder likewidgets
incore
folder to store these widgets?If we have the same API calls, or same local data in different pages, in different features, how can we store them? is it okay to create independent features that have not views itself, just contains
domain
anddata
layer for other features?
This is my repository: https://github.com/thisisyusub/tdd-learn-example
CodePudding user response:
By checking your repo I'm guessing you are talking about your FailureWidget
and LoadingWidget
and by "global widgets" you meant widgets used in multiple features of your application. Now to answer your questions :
In my opinion you can definitely put widgets shared in multiple features in the core/
folder but I would recommend to keep some sort of coherence with your different layers. By that I mean that widgets should be putted inside a presentation
subfolder because only your presentation layer should depend on those.
lib/
|- core/
| |- presentation/
| | |- loading_widget.dart
| | |- failure_widget.dart
Same goes for API calls you want to re-use in multiple features, you can put them inside a data/
subfolder of core/
.
lib/
|- core/
| |- data/
| |- presentation/