我正试图在api调用上获得套接字异常,我正在使用getx GetConnect和GetService进行api调用,但它不返回任何东西,有人可以帮助我,
Future<Response> postDatabyJson(uri,body)async{
try{
print("Api Url "+uri.toString());
print("body "+body.toString());
Response response=await post(uri, body,headers: _mainHeader );
return response;
} on SocketException{
print('internet isssssus');
return Response();
// var retry=await apiDialog();
// if(retry){
// var data= await postDatabyJson(uri,body,);
// return data;
// }
// else{
// return Response(statusCode: 0,statusText: 'Try Again...');
// }
}
catch(e){
return Response(statusCode: 1,statusText: e.toString());
}
}
addcatchSocketException后的关键字
示例:on SocketException catch(error){}