mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: data parse
related #258 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -12,8 +12,8 @@ class HotSearchModel {
|
||||
List<HotSearchItem>? list;
|
||||
|
||||
HotSearchModel.fromJson(Map<String, dynamic> json) {
|
||||
list = json['list']
|
||||
.map<HotSearchItem>((e) => HotSearchItem.fromJson(e))
|
||||
list = (json['list'] as List?)
|
||||
?.map<HotSearchItem>((e) => HotSearchItem.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ class SearchVideoModel {
|
||||
|
||||
SearchVideoModel.fromJson(Map<String, dynamic> json) {
|
||||
numResults = (json['numResults'] as num?)?.toInt();
|
||||
list = json['result']
|
||||
list = (json['result'] as List?)
|
||||
?.where((e) => e['available'] == true)
|
||||
?.map<SearchVideoItemModel>((e) => SearchVideoItemModel.fromJson(e))
|
||||
.map<SearchVideoItemModel>((e) => SearchVideoItemModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class SearchUserModel {
|
||||
|
||||
SearchUserModel.fromJson(Map<String, dynamic> json) {
|
||||
numResults = (json['numResults'] as num?)?.toInt();
|
||||
list = json['result']
|
||||
list = (json['result'] as List?)
|
||||
?.map<SearchUserItemModel>((e) => SearchUserItemModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
@@ -316,12 +316,10 @@ class SearchMBangumiModel {
|
||||
|
||||
SearchMBangumiModel.fromJson(Map<String, dynamic> json) {
|
||||
numResults = (json['numResults'] as num?)?.toInt();
|
||||
list = json['result'] != null
|
||||
? json['result']
|
||||
.map<SearchMBangumiItemModel>(
|
||||
(e) => SearchMBangumiItemModel.fromJson(e))
|
||||
.toList()
|
||||
: [];
|
||||
list = (json['result'] as List?)
|
||||
?.map<SearchMBangumiItemModel>(
|
||||
(e) => SearchMBangumiItemModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,12 +418,9 @@ class SearchArticleModel {
|
||||
|
||||
SearchArticleModel.fromJson(Map<String, dynamic> json) {
|
||||
numResults = (json['numResults'] as num?)?.toInt();
|
||||
list = json['result'] != null
|
||||
? json['result']
|
||||
.map<SearchArticleItemModel>(
|
||||
(e) => SearchArticleItemModel.fromJson(e))
|
||||
.toList()
|
||||
: [];
|
||||
list = (json['result'] as List?)
|
||||
?.map<SearchArticleItemModel>((e) => SearchArticleItemModel.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class SearchSuggestModel {
|
||||
String? term;
|
||||
|
||||
SearchSuggestModel.fromJson(Map<String, dynamic> json) {
|
||||
tag = json['tag']
|
||||
.map<SearchSuggestItem>(
|
||||
tag = (json['tag'] as List?)
|
||||
?.map<SearchSuggestItem>(
|
||||
(e) => SearchSuggestItem.fromJson(e, json['term']))
|
||||
.toList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user