mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-02 16:19:44 +08:00
safely parse up list (#1876)
* fix: 兼容 mid/roomId/count 字段为字符串或数字类型 * update --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
|
|
||||||
class FollowUpModel {
|
class FollowUpModel {
|
||||||
FollowUpModel({
|
FollowUpModel({
|
||||||
this.liveUsers,
|
this.liveUsers,
|
||||||
@@ -49,7 +51,7 @@ class LiveUsers {
|
|||||||
List<LiveUserItem>? items;
|
List<LiveUserItem>? items;
|
||||||
|
|
||||||
LiveUsers.fromJson(Map<String, dynamic> json) {
|
LiveUsers.fromJson(Map<String, dynamic> json) {
|
||||||
count = json['count'] ?? 0;
|
count = Utils.safeToInt(json['count']) ?? 0;
|
||||||
group = json['group'];
|
group = json['group'];
|
||||||
items = (json['items'] as List?)
|
items = (json['items'] as List?)
|
||||||
?.map<LiveUserItem>((e) => LiveUserItem.fromJson(e))
|
?.map<LiveUserItem>((e) => LiveUserItem.fromJson(e))
|
||||||
@@ -63,14 +65,11 @@ class LiveUserItem extends UpItem {
|
|||||||
int? roomId;
|
int? roomId;
|
||||||
String? title;
|
String? title;
|
||||||
|
|
||||||
LiveUserItem.fromJson(Map<String, dynamic> json)
|
LiveUserItem.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
|
||||||
: super(mid: json['mid'] ?? 0) {
|
|
||||||
face = json['face'];
|
|
||||||
isReserveRecall = json['is_reserve_recall'];
|
isReserveRecall = json['is_reserve_recall'];
|
||||||
jumpUrl = json['jump_url'];
|
jumpUrl = json['jump_url'];
|
||||||
roomId = json['room_id'];
|
roomId = Utils.safeToInt(json['room_id']);
|
||||||
title = json['title'];
|
title = json['title'];
|
||||||
uname = json['uname'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ class UpItem {
|
|||||||
UpItem.fromJson(Map<String, dynamic> json) {
|
UpItem.fromJson(Map<String, dynamic> json) {
|
||||||
face = json['face'];
|
face = json['face'];
|
||||||
hasUpdate = json['has_update'];
|
hasUpdate = json['has_update'];
|
||||||
mid = json['mid'] ?? 0;
|
mid = Utils.safeToInt(json['mid']) ?? 0;
|
||||||
uname = json['uname'];
|
uname = json['uname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user