flutter services injection in clean architecture
You've not mentioned to the layers you've adopted from the clean architecture and the use case you need to consider such a design, so it makes your question opinion based.
A service like audio player is more a UI related thing and it does not contain business logic, as it mentioned in the clean architecture use cases layer contains application specific business rules. You should clarify how your playing file involves business logic. Although you still can use bloc for player state management.
mohammad
Updated on December 27, 2022Comments
-
mohammad over 1 year
I am new to clean architecture in flutter,
I know that we should inject our repositories via usecases into presenters like BLoc but I don't know how to use services like an audio service, for example we should pause, resume, seek and ... from the audioServiceImpl,
does it need a usecase for each opearation like play or we should inject the service directly into BLoc ?
-
mohammad over 3 yearsthe layers I have are: domain (entities, usecases), infrastructure (repositories, services), external (datasources, drivers), presentation (BLoc, UI)
-
mohammad over 3 yearsfor now, I have implemented it inside infrastructure, because it needs some persistance for audioPosition and last musics and also last index to remember them, so I think it has some application business logic, is it right ?
-
RaSha over 3 yearsI think you can keep player independent in the presentation layer. In your player bloc, send a request through equivalent use case to fetch the files' play state and then initialize player. When a player event is received in your bloc you can send updated play state to bellow layer in order to persist it.