Add Comment
The addComment()
function allows users to engage in interactive discussions by adding comments to posts. This powerful feature enables users to express their thoughts, ask questions, and engage with other members in a dynamic and collaborative manner. By integrating the comment functionality, developers can foster meaningful conversations and enhance the overall user experience within their application.
Steps to Add Comment
- Create an instance of
AddCommentRequest
with the required parameters:text
andpostId
. - Call the
addComment()
function using the instance of theLMFeedClient
class, passing the request as a parameter. - Use the response as per your requirement.
// Create an instance of AddCommentRequest
AddCommentRequest request = (AddCommentRequestBuilder()
..postId("post_id")
..text("comment_text"))
.build();
// Get the response from calling the function
final AddCommentResponse addCommentResponse = await lmFeedClient.addComment(addCommentRequest);
// Process the response, as per requirement
if (addCommentResponse.success) {
// your function to handle successful addition of comment
handleAddCommentSuccess(addCommentResponse.reply);
} else {
// your function to handle error message
handleAddCommentError(addCommentResponse.errorMessage);
}
Additional Features
Tag a User
To tag a user, use the getTaggingList() function to fetch the list of users that can be tagged, and use the format <<[user.name]|route://user_profile/[user.sdkClientInfo.uuid]>>
to embed it inside the text of the post.
Models
AddCommentRequest
List of parameters for the AddCommentRequest
class
Variable | Type | Description |
---|---|---|
text | String | Comment text |
postId | String | Post ID for comment |
AddCommentResponse
List of parameters for the AddCommentResponse
class
Variable | Type | Description | Optional |
---|---|---|---|
success | bool | API success status | |
errorMessage | String | Error message in failure | ✔ |
reply | Comment | Added comment entity | ✔ |