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
Empty Caseand so on, in which layer and how we can store them to access from any feature? is it okay to create folder like
corefolder 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
datalayer for other features?
This is my repository:
By checking your repo I’m guessing you are talking about your
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
lib/ |- core/ | |- data/ | |- data_sources/
Answered By – Guillaume Roux
Answer Checked By – David Marino (FlutterFixes Volunteer)