颤振response.body为空 [英] Flutter response.body is empty

查看:109
本文介绍了颤振response.body为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此API,在那里我向该网站发出http请求以检索我的数据

I am working with this API where I make an http request to this site to retrieve my Data

https://fantasy.premierleague.com/api/bootstrap-static/

第一次使用它时,我无法检索任何数据,经过一些研究,我通过简单的flutter升级解决了这个问题(我不知道问题是什么,或者升级后为什么解决了该问题),然后几天后,我在该项目上工作,问题又发生了,每次尝试提出请求时,我都变得空了

first time when I used it I couldn't retrieve any data, after some researches I solved the problem with a simple flutter upgrade ( I couldn't know what was the problem or why it was solved after the upgrade ), then after somedays I was working on the project and the problem occurred again and I am getting an empty body every Time I try to make a request

http.get("https://fantasy.premierleague.com/api/bootstrap-static/")

我正在使用此行来获取Response值,然后尝试将其解码为JSON值,但是会发生此错误

I'm using this line to get a Response value and then try to decode it to JSON value but this error happens

exeption occured : FormatException: Unexpected end of input (at character 1)

我已经知道会发生此错误,因为我正在尝试解码一个空的主体,但我不明白为什么会发生这种情况

I already know that this error happens because I am trying to decode an empty body, but I can't understand why this is happening

注意:我尝试了多个其他API URL,它们都正常工作!!

推荐答案

所以我最终切换到flutter master,并且代码运行正常,我仍然不知道为什么它不能在稳定版上运行而在master上运行.无论如何,如果有人遇到此问题,只需切换到master即可,它应该可以正常工作.谢谢.

So I end up switching to flutter master and the code worked perfectly, I still don't know why it doesn't work on stable but works on master. anyway if anyone is having this issue just switch to master and it should work fine. Thanks.

这篇关于颤振response.body为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆