CommentController class
Controller for managing comment operations.
This class orchestrates comment-related business logic by delegating to a CommentService implementation. It handles comment creation, replies, likes, and deletions.
Example:
final service = MyCommentService();
final config = CommentConfig(badWords: '');
final user = UserInfo(uuid: 'user-1', name: 'John Doe');
final controller = CommentController(
service: service,
config: config,
user: user,
);
Constructors
- CommentController({required CommentService service, required CommentConfig config, required UserInfo user})
- Creates a new CommentController.
Properties
- config → CommentConfig
-
Configuration for the comments module.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- service → CommentService
-
The service implementation for comment operations.
final
- user → UserInfo
-
Information about the current user.
final
Methods
-
deleteComment(
String commentId) → Future< void> - Deletes a comment.
-
fetchComments(
String entityId) → Future< List< Comment> > - Fetches comments for a specific entity.
-
getReplies(
String commentId, [int page = 1]) → Future< List< Comment> > -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postComment(
String entityId, String content) → Future< Comment?> - Posts a new comment for an entity.
-
postReply(
String entityId, String parentCommentId, String content) → Future< Comment?> - Posts a reply to an existing comment.
-
toggleLike(
String commentId) → Future< Comment?> - Toggles the like status of a comment.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited