addComment method

Future<void> addComment(
  1. String content
)

Adds a new comment to the entity.

Creates a new top-level comment (not a reply). The comment is inserted at the beginning of the comments list.

content is the text content of the comment.

If the comment creation fails, this method does nothing (the comment is not added to the list).

Implementation

Future<void> addComment(String content) async {
  final Comment? comment = await controller.postComment(postId, content);
  if (comment == null) return;
  _comments.insert(0, comment);
  notifyListeners();
}