为啥我在flutter中更新http包后不能在http.post方法中放一个字符串

Posted

技术标签:

【中文标题】为啥我在flutter中更新http包后不能在http.post方法中放一个字符串【英文标题】:Why can't I put a string in the http.post method after update http package in flutter为什么我在flutter中更新http包后不能在http.post方法中放一个字符串 【发布时间】:2021-06-04 00:27:58 【问题描述】:

在我将 http 包更新到版本 0.13.0 后,我的 IP 地址无法使用 http.post() 方法

错误:无法将参数类型“String”分配给参数类型“Uri”。

但在以前的版本中,我可以使用字符串作为我的 uri,没有任何问题,或者我应该使用某种方法将其转换为 Uri 类型而不是字符串?

enter image description here

enter image description here

【问题讨论】:

这能回答你的问题吗? The argument type 'String' can't be assigned to the parameter type 'Uri' 【参考方案1】:

参数应该是Uri 而不是String

要将您的字符串解析为 URI,您可以这样做:Uri.parse(my_string)

【讨论】:

以上是关于为啥我在flutter中更新http包后不能在http.post方法中放一个字符串的主要内容,如果未能解决你的问题,请参考以下文章

为啥我在flutter_web中更新HtmlView时得到_state!= _PlatformViewState.disposed不是真正的异常?

添加 cloud_firebase 包后,我的 Flutter App 没有运行

为啥我不能导入我刚刚安装的包?

为啥在 Flutter 中,PlatformView 不能缩小到自己的大小?

在 pubspec.yaml 中添加 Google Maps 包后,Flutter iOS 应用程序将无法构建

Flutter嵌套列表视图为啥我不能使用行?