问题描述
我已将 http 版本添加到 pubspec.yaml 文件中的 ^0.13.0,我只需要从 Public-apis.io 获取 Yes NO API 请求即可生成一些 Yes/No GIF,同时使用 Get 请求它说,
不能将参数类型“String”分配给参数类型“Uri”。
对此有什么解决方案吗?enter image description here
解决方法
你应该使用:
http.get(Uri.parse("https://yesno.wtf/api"))
,
它有效:
Response response = await get(Uri.https("owlbot.info","/api/v4/dictionary/"));
或者,使用令牌和参数:
Response response = await get(Uri.https("owlbot.info","/api/v4/dictionary/"+ _controller.text.trim()),headers: {"Authorization": "Token " + _token});