使用 flutter http 包获取天气信息

问题描述

我想从 openweathermap API 获取协调基地的当前天气信息。 为此,我使用了 Flutter 的 HTTP 包。

当我使用这种方法时,问题就出现了

还有一个问题是...我在 Memu App Player 上获得了这些坐标,但在真正的 android 设备和 Android Studio 的自己的模拟器上没有给出。

void getWeatherData()async{
String url = 'http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=331533c0cc2197e929ea79cdb2a70e33';
Response response = await get(Uri.parse(url));
print(response.body);  }

这应该完全给我 API 结果,但是当我运行我的应用程序时它给了我这个错误

Unhandled Exception: Bad state: Insecure HTTP is not allowed by platform: http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=331533c0cc2197e929ea79cdb2a70e33

解决方法

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

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

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