skip to Main Content

I need to request permissions for the camera and Bluetooth in one of my features, and I’m using the permission_handler package. I’m not sure if I should inject the permission_handler package inside the feature’s data layers by passing it as a local datasource, or if I should create a separate feature specifically for handling permissions with different use cases for the camera and Bluetooth.

For example, let’s say I need to access camera permission in the profile feature to click an image.

Is adding PermissionHandler in ProfileLocalDataSourceImpl correct?

class ProfileLocalDataSourceImpl implements ProfileLocalDataSource {

    private final SharedPreferences sharedPref;
    private final PermissionHandler permissionHandler;

    // Constructor and methods...
}

Or should I create a new feature, such as ProfileHandling, with its own data, domain, and presentation layers?"

2

Answers


  1. I think it’s reasonable to implement the permission handler as a feature. This is not an infrastructure layer (which can be changed), but an application layer, that is, an application service (controller) which can use infrastructure storage service (for example, SharedPreferences, a text file, or a remote database).

    Login or Signup to reply.
  2. The ProfileLocalDataSourceImpl only focuses on data from your local/remote storage. It doesn’t need to be aware of permission handling.

    So a good approach is to create a common usecase i.e. RequestCameraPermissionUsecase.

    Keeping your permission logic separate from data sources promotes Separation of Concerns.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search