Comment.fromJson constructor
Comment.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Comment.fromJson(Map<String, dynamic> json) {
return Comment(
id: json['id'],
content: json['content'] ?? '',
postId: json['post_id'] ?? 0,
parentId: json['parent_id'],
replies: json['replies'] != null
? List<Comment>.from(json['replies'].map((x) => Comment.fromJson(x)))
: [],
likesCount: json['likes_count'] ?? 0,
user: CommunityUser.fromJson(json['user'] ?? {}),
isLikedByUser: json['is_liked_by_user'],
createdAt: DateTime.parse(json['created_at']),
updatedAt: DateTime.parse(json['updated_at']),
);
}