Future fire(BaseRequest request) async {
HiNetResponse response;
var error;
try {
response = await send(request);
} on HiNetError catch (e) {
error = e;
response = e.data;
printLog(e.message);
} catch (e) {
error = e;
printLog(e);
}
if (response == null) {
printLog(error);
}
var result = response.data;
printLog(result);
var status = response.statusCode;
switch (status) {
case 200:
return result;
break;
case 401:
throw NeedLogin();
break;
case 403:
throw NeedAuth(result.toString(), data: result);
break;
default:
throw HiNetError(status, result.toString(), data: result);
break;
}
}
fire
方法中无网络的时候报上面的错. 问答区你说对response做一下保护是什么意思?
一次性掌握Flutter高阶技能+商业级复杂项目架构设计与开发方案
了解课程