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 a Chatroom for open ChatRoom

  1. Create an object of the FollowChatroomRequest class, pass false to value.
  2. For following a chatroom call followChatroom() present in LMChatClient class using your request object.
  3. Process the response (LMResponse<FollowChatroomResponse>) as per your requirement.
// To leave a chatroom, set the value to false
FollowChatroomRequest request = (FollowChatroomRequestBuilder()
..chatroomId(70989)
..memberId(87103)
..value(false)).build();

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

if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}

Models

FollowChatroomRequest

List of parameters for the FollowChatroomRequest class

VariableTypeDescriptionOptional
chatroomIdintChatroom Id
memberIdintMember Id✔️
valueboolFollow value

FollowChatroomResponse

List of parameters for the FollowChatroomResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageString?Error message in case of failure✔️

Steps to Leave a Chatroom for secret ChatRoom

  1. Create an object of the DeleteParticipantRequest class using the DeleteParticipantRequestBuilder class.
  2. Using the request, call the deleteParticipant() method present in the LMChatClient class.
  3. Process the response (LMResponse<DeleteParticipantResponse>) as per your requirement.
final DeleteParticipantRequest request = (DeleteParticipantRequestBuilder()
..chatroomId(widget.chatroom.id)
..isSecret(true))
.build();

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

if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}

Models

DeleteParticipantRequest

List of parameters for the DeleteParticipantRequest class

VariableTypeDescriptionOptional
chatroomIdintChatroom Id
isSecretboolSet to true in case of secret chatroom✔️

DeleteParticipantResponse

List of parameters for the DeleteParticipantResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageString?Error message in case of failure✔️