From 15f84712cdea65fcfb10a816b0892c9b9cca5269 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 12 Apr 2025 20:53:59 +0800 Subject: [PATCH] fix: parse reply Signed-off-by: bggRGjQaUbCoE --- lib/models/video/reply/data.dart | 11 +++++++---- lib/models/video/reply/item.dart | 9 ++++++--- lib/models/video/reply/member.dart | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/models/video/reply/data.dart b/lib/models/video/reply/data.dart index 4cc15c19..39ea6df2 100644 --- a/lib/models/video/reply/data.dart +++ b/lib/models/video/reply/data.dart @@ -58,8 +58,9 @@ class ReplyReplyData { ReplyItemModel? root; ReplyReplyData.fromJson(Map json) { - page = ReplyPage.fromJson(json['page']); - config = ReplyConfig.fromJson(json['config']); + page = json['page'] == null ? null : ReplyPage.fromJson(json['page']); + config = + json['config'] == null ? null : ReplyConfig.fromJson(json['config']); replies = (json['replies'] as List?) ?.map( (item) => ReplyItemModel.fromJson(item, json['upper']['mid'])) @@ -69,7 +70,9 @@ class ReplyReplyData { item, json['upper']['mid'], isTopStatus: true)) .toList(); - upper = ReplyUpper.fromJson(json['upper']); - root = ReplyItemModel.fromJson(json['root'], json['upper']['mid']); + upper = json['upper'] == null ? null : ReplyUpper.fromJson(json['upper']); + root = json['root'] == null + ? null + : ReplyItemModel.fromJson(json['root'], json['upper']?['mid']); } } diff --git a/lib/models/video/reply/item.dart b/lib/models/video/reply/item.dart index bdda853f..5d8c211f 100644 --- a/lib/models/video/reply/item.dart +++ b/lib/models/video/reply/item.dart @@ -84,13 +84,16 @@ class ReplyItemModel { parentStr = json['parent_str']; like = json['like']; action = json['action']; - member = ReplyMember.fromJson(json['member']); - content = ReplyContent.fromJson(json['content']); + member = + json['member'] == null ? null : ReplyMember.fromJson(json['member']); + content = + json['content'] == null ? null : ReplyContent.fromJson(json['content']); replies = (json['replies'] as List?) ?.map((item) => ReplyItemModel.fromJson(item, upperMid)) .toList(); assist = json['assist']; - upAction = UpAction.fromJson(json['up_action']); + upAction = + json['up_action'] == null ? null : UpAction.fromJson(json['up_action']); invisible = json['invisible']; replyControl = json['reply_control'] == null ? null diff --git a/lib/models/video/reply/member.dart b/lib/models/video/reply/member.dart index ad10c143..221c0738 100644 --- a/lib/models/video/reply/member.dart +++ b/lib/models/video/reply/member.dart @@ -28,7 +28,8 @@ class ReplyMember { sign = json['sign']; avatar = json['avatar']; level = json['level_info']['current_level']; - pendant = Pendant.fromJson(json['pendant']); + pendant = + json['pendant'] == null ? null : Pendant.fromJson(json['pendant']); officialVerify = json['official_verify']; vip = json['vip']; fansDetail = json['fans_detail'];