imageComment method

dynamic imageComment({
  1. String? postId,
  2. required String userId,
  3. required List<Media> list,
})

Implementation

imageComment(
    {String? postId,
    required String userId,
    required List<Media> list}) async {
  try {
    List<String> imagePaths = [];
    if (list.isNotEmpty) {
      list.forEach((element) {
        imagePaths.add(element.path);
      });
    }

    if (replyYes) {
      var subComment = SubCommentDTO(
        postId: '$postId',
        commentedBy: "commentedBy",
        userId: "XXXXX-001",
        userDispalyName: "KM",
        commentedDate: DateTime.now(),
        comment: textController.text,
        commentImgUrl: imagePaths,
        commentLikeCounts: getEmojiesForLike(),
        likesUsers: [],
        tagTo: '@${replyTo}',
      );
      listOfComments[mainCommnetId].replies.add(subComment);
      changCommentState();
    } else {
      var mainComment = CommentDTO(
        postId: '$postId',
        commentedBy: "Login User",
        userId: "Login User Id",
        userDispalyName: "SA",
        commentedDate: DateTime.now(),
        comment: textController.text,
        commentImgUrl: imagePaths,
        commentLikeCounts: getEmojiesForLike(),
        replies: [],
        likesUsers: [],
      );

      listOfComments.add(mainComment);
      changCommentState();
    }
  } catch (e) {
    changCommentState();
  }
}