parseCommentData method
Read the document data and convert it to a list of CommentModel objects.
Implementation
List<CommentModel> parseCommentData(Map<String, dynamic>? data) {
final comments = data?.entries
// Filter out the lastEdited and type fields
.where((element) => int.tryParse(element.key) != null)
.map((comment) => CommentModel.fromPartialJson(comment))
.toList();
comments?.sort((a, b) => a.commentDate!.isBefore(b.commentDate!) ? 1 : -1);
return comments ?? [];
}