flatter http.post从不返回响应

flatter http.post从不返回响应,http,asynchronous,post,async-await,flutter,Http,Asynchronous,Post,Async Await,Flutter,我对弗利特有一个真正的问题 我正在使用“http”库向我的Express服务器发出http请求。 当我试图发送一个HTTPPOST请求时,我的服务器确实收到了它,但我的颤振代码只是停止执行 print("here"); http.Response response = await http.post(url, body:data); print("got response!"); // Never executes 我在Logcat中没有看到任何错误,即使我使用假url或关闭服务器,同样的结果

我对弗利特有一个真正的问题

我正在使用“http”库向我的Express服务器发出http请求。 当我试图发送一个HTTPPOST请求时,我的服务器确实收到了它,但我的颤振代码只是停止执行

print("here");
http.Response response = await http.post(url, body:data);
print("got response!"); // Never executes
我在Logcat中没有看到任何错误,即使我使用假url或关闭服务器,同样的结果总是会发生。执行只是停止,没有任何错误

有人知道为什么吗

谢谢

试试下面的方法

var response = await http.post(Uri.encodeFull(url), body:data);
final statusCode = response.statusCode;
print('Response Status code: $statusCode');
谢谢你的帮助

问题是服务器没有关闭连接,一段时间后引发了未处理的异常


但是,直到我更新了我的颤振版本后,这个异常才出现在logcat上

你能分享你的url吗?如果没有,您是否使用邮递员查看返回的数据?您是否可以共享您使用的颤振版本?