未为类型“Uri”定义运算符“+”

问题描述

我有一个项目,我使用 http 包来发出各种 http 请求。我最近更新了该包,但无法将 url 链接附加到我拥有的基本 url 的末尾。这是示例代码

  var _url = Uri.parse('url here');

  var token;

  _getToken() async {
    SharedPreferences localStorage = await SharedPreferences.getInstance();
    token = jsonDecode(localStorage.getString('token'))['token'];
  }

  authData(data,apiUrl) async {
    try {
      var fullUrl = _url +  apiUrl;
      return await http.post(fullUrl,body: jsonEncode(data),headers: _setHeaders());
    } catch (e) {
      print(e);
    }
  }

这是它显示的错误

The operator '+' isn't defined for the type 'Uri'.
Try defining the operator '+'.dartundefined_operator

错误发生在 var fullUrl = _url + apiUrl; 尤其是 + 运算符。在更新之前它运行良好但是我找不到解决方案

解决方法

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

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

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