Flutter 一些用户在颤振时收到socketException
为什么总是出现SocketException?有时它是有效的。我的密码里有什么吗 如何找到确切的错误Flutter 一些用户在颤振时收到socketException,flutter,dart,flutter-http,Flutter,Dart,Flutter Http,为什么总是出现SocketException?有时它是有效的。我的密码里有什么吗 如何找到确切的错误 class ApiProvider { final http.Client client; ApiProvider({HttpClient client}) : this.client = client ?? http.Client(); Future<dynamic> sendBook(Map data) async { var responseJso
class ApiProvider {
final http.Client client;
ApiProvider({HttpClient client}) : this.client = client ?? http.Client();
Future<dynamic> sendBook(Map data) async {
var responseJson;
var uri = Uri.parse('$url');
uri = uri.replace(queryParameters: data);
try {
final response = await http.post(uri);
responseJson = _response(response);
return responseJson;
} on SocketException {
//Is there any way to find what is this error?
throw FetchDataException('Something Happening, Please try again!');
}
}
要获得准确的错误代码,您必须更改SocketException{上的行以捕获e,s{其中e是引发的异常,s是异常的堆栈跟踪。要获得准确的错误代码,您必须更改SocketException{上的行以捕获e,s{其中e是引发的异常,s是异常的堆栈跟踪。
void main() async {
HttpOverrides.global = OBHttpOverrides();