1

为什么这总是让 SocketException 开启?有时它正在工作。我的代码上有什么吗?

如何找到确切的错误?

 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!');
    }
  }

主要方法

void main() async {
  HttpOverrides.global = OBHttpOverrides();
4

0 回答 0