我有一个项目,我使用 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;
专门发生在 + 运算符处。在更新之前它运行良好但是我找不到它的解决方案