一些用户在Flutter上获取socketException

问题描述

为什么总是打开SocketException?有时它正在工作。我的代码上有东西吗?

如何找到确切的错误

bool IsIsogram(char *str)
{
  int isogram[256];
  int i,len_str,cpt,occs;
  unsigned char c;

  for (i = 0; str[i] != '\0'; i++) {
      len_str=i;
  }

  for (i=0; i<256;i++){isogram[i]=0;} // i <=256 goes out of bounds
  for(i=0; i <= len_str; i++){
      c = str[i];
      c = tolower(c);
      str[i] = c;
  }
 cpt=0;
 for (i = 0; i < len_str; i++) {
    c = str[i];
    isogram[c]=isogram[c]+1;
  }

  for (i = 0; i < 256; i++) {
  occs = isogram[i];
  if (occs > 0) {
    cpt++;
  }
  }
  if (cpt==len_str) {
      return true;
  }
  else{
  return false;
  }
}

主要方法

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)