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
- Create an object of the
FollowChatroomRequest
class. - Call the
followChatroom()
function using the instance of theLMChatClient
class. - 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
Variable | Type | Description | Optional |
---|---|---|---|
chatroomId | int | Unique ID of the chatroom | |
memberId | int? | Unique ID of the member | ✔️ |
value | bool | Set to true to follow, false to unfollow |
Steps to Leave a Secret Chatroom
- Create an object of the
DeleteParticipantRequest
class. - Call the
deleteParticipant()
function using the instance of theLMChatClient
class. - 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
Variable | Type | Description | Optional |
---|---|---|---|
chatroomId | int | Unique ID of the chatroom | |
isSecret | bool? | Indicates if the chatroom is secret | ✔️ |
memberId | String? | Unique ID of the member to be deleted |