Skip to main content

Leave Chatroom

Leaving a chatroom with LikeMinds Flutter Chat SDK allows you to exit a chatroom that you no longer want to be a part of.

Steps to Leave an Open Chatroom

  1. Create an object of the FollowChatroomRequest class.
  2. Call the followChatroom() function using the instance of the LMChatClient class.
  3. Process the response LMResponse<void> as per your requirement.
// To leave a chatroom, set the value to false
FollowChatroomRequest request = (FollowChatroomRequestBuilder()
..chatroomId("ENTER_CHATROOM_ID")
..memberId("ENTER_MEMBER_ID")
..value(true)) //Set to false to leave a chatroom
.build();

LMResponse<void> response = await lmChatClient.followChatroom(request);

if (response.success) {
// your function to handle successful follow action
handleFollowSuccess();
} else {
// your function to handle follow error
handleFollowError(response.errorMessage);
}

Models

FollowChatroomRequest

List of parameters for the FollowChatroomRequest class

VariableTypeDescriptionOptional
chatroomIdintUnique ID of the chatroom
memberIdint?Unique ID of the member✔️
valueboolSet to true to follow, false to unfollow

Steps to Leave a Secret Chatroom

  1. Create an object of the DeleteParticipantRequest class.
  2. Call the deleteParticipant() function using the instance of the LMChatClient class.
  3. Process the response LMResponse<void> as per your requirement.

When deleting a participant from a secret chatroom, ensure that the isSecret parameter is set to true.

DeleteParticipantRequest request = (DeleteParticipantRequestBuilder()
..chatroomId("ENTER_CHATROOM_ID")
..isSecret(true)
..memberId("ENTER_MEMBER_ID"))
.build();

LMResponse<void> response = await lmChatClient.deleteParticipant(request);

if (response.success) {
// your function to handle successful deletion
handleDeleteSuccess();
} else {
// your function to handle deletion error
handleDeleteError(response.errorMessage);
}

Models

DeleteParticipantRequest

List of parameters for the DeleteParticipantRequest class

VariableTypeDescriptionOptional
chatroomIdintUnique ID of the chatroom
isSecretbool?Indicates if the chatroom is secret✔️
memberIdString?Unique ID of the member to be deleted