我有这个:
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
总是会引发错误:
类型“List<String>”不是类型转换中的“String”的子类型
我不知道Dart还想从我这里得到什么。
_filters
而不是List<String>,并删除<String>。这在Dart中应该已经足够了。 - Bostrottoken
是一个字符串。它来自于final token = prefs.getString('token');
。将其更改为var
并不能解决问题。问题在于,错误信息根本没有意义,所以调试甚至无从开始。 - KhoPhitype 'List<dynamic>' is not a subtype of type 'String' in type cast
。 - KhoPhibody
可以接受List
吗?在我看来,它似乎试图将其转换为String
,显然这是行不通的。 - creativecreatorormaybenot