checkPermission function

bool checkPermission({
  1. PermissionType? permissionTypeCheck,
  2. ProduceSources? produceSourcesCheck,
})

Implementation

bool checkPermission({
  PermissionType? permissionTypeCheck,
  ProduceSources? produceSourcesCheck,
}) {
  final permissions = permissionsValueNotifier.value;
  bool? isPermissionTypePermitted = permissions[permissionTypeCheck?.name];
  bool? isProduceSourcesPermitted =
      permissions['canProduceSources'][produceSourcesCheck?.name];

  if (isPermissionTypePermitted == true || isProduceSourcesPermitted == true) {
    return true;
  } else {
    if (permissionTypeCheck != null) {
      logger.e("${permissionTypeCheck.name} access required.");
    } else if (produceSourcesCheck != null) {
      logger.e("${produceSourcesCheck.name} access required.");
    }
    return false;
  }
}