fix: null safety

This commit is contained in:
bggRGjQaUbCoE
2024-08-29 10:42:03 +08:00
parent 27e0fcb1c5
commit 7c53da02c8

View File

@@ -352,20 +352,18 @@ class VideoHttp {
// (取消)点赞 // (取消)点赞
static Future likeVideo({required String bvid, required bool type}) async { static Future likeVideo({required String bvid, required bool type}) async {
var res = await Request().post( var res = await Request().post(Api.likeVideo, queryParameters: {
Api.likeVideo, 'aid': IdUtils.bv2av(bvid),
queryParameters: { 'like': type ? 0 : 1,
'aid': IdUtils.bv2av(bvid), 'access_key': GStorage.localCache
'like': type ? 0 : 1, .get(LocalCacheKey.accessKey, defaultValue: {})['value'],
'access_key': GStorage.localCache }
.get(LocalCacheKey.accessKey, defaultValue: {})['value'], // queryParameters: {
} // 'bvid': bvid,
// queryParameters: { // 'like': type ? 1 : 2,
// 'bvid': bvid, // 'csrf': await Request.getCsrf(),
// 'like': type ? 1 : 2, // },
// 'csrf': await Request.getCsrf(), );
// },
);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'data': res.data['data']}; return {'status': true, 'data': res.data['data']};
} else { } else {
@@ -594,9 +592,17 @@ class VideoHttp {
'csrf': await Request.getCsrf(), 'csrf': await Request.getCsrf(),
}); });
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'msg': res.data['result']['toast']}; return {
'status': true,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
};
} else { } else {
return {'status': false, 'msg': res.data['result']['toast']}; return {
'status': false,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
};
} }
} }
@@ -607,9 +613,17 @@ class VideoHttp {
'csrf': await Request.getCsrf(), 'csrf': await Request.getCsrf(),
}); });
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return {'status': true, 'msg': res.data['result']['toast']}; return {
'status': true,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
};
} else { } else {
return {'status': false, 'msg': res.data['result']['toast']}; return {
'status': false,
'msg':
res.data['result'] == null ? 'failed' : res.data['result']['toast']
};
} }
} }