Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix: failed to parse comment response

bggRGjQaUbCoEbaa855101bc1
diff --git a/lib/modules/comments/comment_response.dart b/lib/modules/comments/comment_response.dart
index 84b28928..5decc678 100644
--- a/lib/modules/comments/comment_response.dart
+++ b/lib/modules/comments/comment_response.dart
@@ -10,11 +10,11 @@ class CommentResponse {
});
factory CommentResponse.fromJson(Map<String, dynamic> json) {
- var list = json['list'] as List;
- List<CommentItem> resCommentList =
- list.map((i) => CommentItem.fromJson(i)).toList();
+ List? list = (json['list'] as List?) ?? (json['data'] as List?);
+ List<CommentItem>? resCommentList =
+ list?.map((i) => CommentItem.fromJson(i)).toList();
return CommentResponse(
- commentList: resCommentList,
+ commentList: resCommentList ?? <CommentItem>[],
total: json['total'],
);
}
@@ -42,10 +42,10 @@ class EpisodeCommentResponse {
});
factory EpisodeCommentResponse.fromJson(List<dynamic> json) {
- List<EpisodeCommentItem> resCommentList =
- json.map((i) => EpisodeCommentItem.fromJson(i)).toList();
+ List<EpisodeCommentItem>? resCommentList =
+ (json as List?)?.map((i) => EpisodeCommentItem.fromJson(i)).toList();
return EpisodeCommentResponse(
- commentList: resCommentList,
+ commentList: resCommentList ?? <EpisodeCommentItem>[],
);
}
@@ -60,4 +60,4 @@ class EpisodeCommentResponse {
'list': commentList,
};
}
-}
\ No newline at end of file
+}