fix: 数据格式null

This commit is contained in:
guozhigq
2023-08-31 09:55:57 +08:00
parent 4f6dd68954
commit 3c1fa82010
4 changed files with 28 additions and 14 deletions

View File

@ -56,9 +56,19 @@ class SearchPanelController extends GetxController {
// 匹配输入内容如果是AV、BV号且有结果 直接跳转详情页
Map matchRes = IdUtils.matchAvorBv(input: keyword);
List matchKeys = matchRes.keys.toList();
String bvid = resultList.first.bvid;
String? bvid;
try {
bvid = resultList.first.bvid;
} catch (_) {
bvid = null;
}
// keyword 可能输入纯数字
int aid = resultList.first.aid;
int? aid;
try {
aid = resultList.first.aid;
} catch (_) {
aid = null;
}
if (matchKeys.isNotEmpty && searchType == SearchType.video ||
aid.toString() == keyword) {
String heroTag = Utils.makeHeroTag(bvid);