Skip to main content

Toggle Block

The toggleBlock() function is used to block or unblock a user based on the parameters provided in the BlockUserRequest. It returns an LMResponse.

Steps to Block or Unblock a User

  1. Build a BlockUserRequest object using the BlockUserRequestBuilder class.
  2. Call the toggleBlock() function using an instance of the LMFeedClient class.
  3. Use the response LMResponse as per your requirement.
// Build the request object
final BlockUserRequest blockUserRequest = (BlockUserRequestBuilder()
..uuid("USER_UUID_HERE") // Replace with the actual user UUID
..shouldBlock(true)) // pass true to block a user
.build();

// Get the response from calling the function
final LMResponse<void> blockUserResponse = await lmFeedClient.toggleBlock(blockUserRequest);

// Process the response, as per requirement
if (blockUserResponse.success) {
// Your function to handle successful block action
handleBlockSuccess();
} else {
// Your function to handle error message
handleBlockError(blockUserResponse.errorMessage);
}

info

To check if a user is blocked or not, refer to this Get Blocked User

Models

BlockUserRequest

The BlockUserRequest class represents the parameters required to block or unblock a user. Below are the details of the BlockUserRequest model:

VariableTypeDescriptionOptional
uuidStringThe unique identifier (UUID) of the user.No
shouldBlockbooltrue to block the user, false to unblock.No