dart - 输入'列表' 不是类型转换中类型 'String' 的子类型
问题描述
我有这个:
List<String> _filters = <String>[8, 11];
我将它传递_filters
到这个端点:
this.api.setInterests(token, _filters)
.then((res) {
print(res);
});
看起来像这样:
Future setInterests(String token, List<String> interests) {
return _netUtil.post(BASE_URL + "/setinterests", body: {
"token": token,
"interests": interests
}).then((dynamic res) {
return res;
});
}
传递_filters
总是抛出错误:
type 'List<String>' is not a subtype of type 'String' in type cast
我不知道飞镖还想从我这里得到什么。
解决方案
我找到了答案。我刚刚添加.toString()
到_filters
列表中。
this.api.setInterests(token, _filters.toString())
.then((res) {
print(res);
});
推荐阅读
- delphi - TIdHTTP:为 HTTP 请求选择传出 IP?
- c - 为什么在c中需要头文件
- python - 如何将表情符号替换为文本中的单词?
- docker - Nginx .js 文件的位置
- java - Javax.sound.midi studying code not working on MacOS X
- python - netscanner 中 Scapy ARP 请求的问题
- python-3.x - 用于将不同的文件循环到同一行列表中
- ios - How to access the methods for my custom UITableViewCell in my viewController
- html - 标签内的子标签错误的换行符
- xml - 如何从特定节点克隆所有子节点