copyWith method
Creates a copy of this comment with the given fields replaced.
All parameters are optional. If a parameter is not provided, the value from this comment is used.
Returns a new Comment instance with updated values.
Example:
final updated = comment.copyWith(
likeCount: comment.likeCount! + 1,
isLiked: true,
);
Implementation
Comment copyWith({
String? id,
DateTime? date,
String? parentId,
String? content,
String? entityId,
String? userId,
String? username,
int? likeCount,
int? replyCount,
bool? isLiked,
bool? isMine,
List<Comment>? replies,
}) {
return Comment(
id: id ?? this.id,
date: date ?? this.date,
parentId: parentId ?? this.parentId,
content: content ?? this.content,
entityId: entityId ?? this.entityId,
userId: userId ?? this.userId,
username: username ?? this.username,
likeCount: likeCount ?? this.likeCount,
replyCount: replyCount ?? this.replyCount,
isLiked: isLiked ?? this.isLiked,
isMine: isMine ?? this.isMine,
replies: replies ?? this.replies,
);
}