Reputation: 61
I am planning to use clean architecture in Flutter to develop my upcoming projects. Currently, I'm using libraries such as flutter_bloc and get_it. The entire project is composed of core, features, and infrastructure.The problems I've encountered are as follows:
While using the network library, I followed the conventional approach from previous projects by encapsulating all the APIs in the project using an api_client. When encapsulating the api_client, each request returns a specific model object. However, in clean architecture, model objects should be placed in the data layer. So now I'm a bit confused: should I not encapsulate this client? If not, do I need to handle it separately in the data layer under each feature? If multiple features share the same client, is it reasonable for me to create a common module within features to handle it?
Dealing with some third-party libraries presents a similar issue. Should I write a separate manager to encapsulate them? If I do encapsulate them, where should I place the management class? The answer I've found so far is to put it in infrastructure, which is at the same level as core and features. In this case, should I treat it as a feature without a presentation layer within this directory, or handle it differently?
Upvotes: 1
Views: 24