fix null condition

This commit is contained in:
Simon Ding
2024-07-19 15:13:25 +08:00
parent 7c299677a0
commit a4b13231df

View File

@@ -59,7 +59,6 @@ class SearchPageData
if (rsp.code != 0) { if (rsp.code != 0) {
throw rsp.message; throw rsp.message;
} }
var sp = SearchResponse.fromJson(rsp.data); var sp = SearchResponse.fromJson(rsp.data);
return sp.results ?? List.empty(); return sp.results ?? List.empty();
} }
@@ -117,7 +116,7 @@ class SearchResponse {
page: json["page"], page: json["page"],
totalPage: json["total_page"], totalPage: json["total_page"],
totalResults: json["total_results"], totalResults: json["total_results"],
results: (json["results"] as List) results: json["results"] == null ? []: json["results"]
.map((v) => SearchResult.fromJson(v)) .map((v) => SearchResult.fromJson(v))
.toList()); .toList());
} }