在 Flutter 中获取请求:- 'String' 不能分配给参数类型 'Uri'
问题描述:
我已将 http 版本添加到 pubspec.yaml 文件中的 ^0.13.0,我只需要从 Public-apis.io 获取 Yes NO API 请求即可生成一些 Yes/No GIF,同时使用 Get 请求它说,
I have added the http version to ^0.13.0 in pubspec.yaml file and I just need to get the Yes NO API request from the Public-apis.io to generate some Yes/No GIFs, while using the Get request it says,
不能将参数类型String"分配给参数类型Uri".
The argument type 'String' can't be assigned to the parameter type 'Uri'.
对此有任何解决方案吗?在此处输入图片说明
Any solution for this?enter image description here
答
你应该使用:
http.get(Uri.parse("https://yesno.wtf/api"))