flutter - 一些用户在 Flutter 上遇到 socketException
问题描述
为什么这总是让 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();
解决方案
推荐阅读
- javascript - 你如何为常规 JavaScript 使用内联 TypeScript 注释?
- javascript - 防止 getElementById 过早执行?
- arrays - 如何在 NEO4 Cypher 中创建属性数组?
- javascript - 地理定位已在本文档中被功能政策禁用
- python - 为什么在计算数组的子集时,变量名似乎有所不同?
- javascript - 如何使用 Material UI React 显示菜单列表中的哪个项目被选中?
- emacs - Emacs 奇怪的行移动
- ruby-on-rails - 在 Rails 5 中使用不同的 redis 存储进行会话和缓存
- visualization - 如何可视化纵向数据?
- mysql - 无法在 Linux 上设置对 MySQL 服务器的远程访问