我通过使用以下代码解决了问题
Futurepost(String url,var body)async{ return await http .post(Uri.encodeFull(url), body: body, headers: {"Accept":"application/json"}) .then((http.Response response) { // print(response.body); final int statusCode = response.statusCode; if (statusCode < 200 || statusCode > 400 || json == null) { throw new Exception("Error while fetching data"); } return _decoder.convert(response.body); }); }