fix: return null

This commit is contained in:
Simon Ding
2024-11-01 22:05:06 +08:00
parent 0b1bd8226d
commit 8ce7045466
2 changed files with 8 additions and 4 deletions

View File

@@ -131,7 +131,7 @@ class APIs {
if (sp.code != 0) { if (sp.code != 0) {
throw sp.message; throw sp.message;
} }
return sp.data as List<String>; return sp.data==null? []:sp.data as List<String>;
} }
static Future<List<String>> downloadAllMovies() async { static Future<List<String>> downloadAllMovies() async {
@@ -142,7 +142,7 @@ class APIs {
if (sp.code != 0) { if (sp.code != 0) {
throw sp.message; throw sp.message;
} }
return sp.data as List<String>; return sp.data==null? []:sp.data as List<String>;
} }
static Future<String> parseTvName(String s) async { static Future<String> parseTvName(String s) async {

View File

@@ -123,11 +123,15 @@ class WelcomePageState extends ConsumerState<WelcomePage> {
onPressed: () async { onPressed: () async {
if (uri == WelcomePage.routeMoivie) { if (uri == WelcomePage.routeMoivie) {
await APIs.downloadAllMovies().then((v) { await APIs.downloadAllMovies().then((v) {
showSnakeBar("开始下载电影:$v"); if (v.isNotEmpty) {
showSnakeBar("开始下载电影:$v");
}
}); });
} else { } else {
await APIs.downloadAllTv().then((v) { await APIs.downloadAllTv().then((v) {
showSnakeBar("开始下载剧集:$v"); if (v.isNotEmpty) {
showSnakeBar("开始下载剧集:$v");
}
}); });
} }
}, },