I have this:
List<String> _filters = <String>[8, 11];
I pass this _filters into this endpoint:
this.api.setInterests(token, _filters)
.then((res) {
print(res);
});
which looks like this:
Future setInterests(String token, List<String> interests) {
return _netUtil.post(BASE_URL + "/setinterests", body: {
"token": token,
"interests": interests
}).then((dynamic res) {
return res;
});
}
Passing _filters always throws the error:
type 'List<String>' is not a subtype of type 'String' in type cast
I don't know what else dart wants from me.
_filterswith var instead of List<String> and remove <String>. That should be enough for most purposes in Dart.tokenis a string. It comes fromfinal token = prefs.getString('token');. Changing tovardoesn't fix it. The thing is, the error message makes absolutely no sense, so debugging is vague to even begin withtype 'List<dynamic>' is not a subtype of type 'String' in type cast.bodycan take inList's? It looks like it is trying to cast it to aStringto me, which obviously does not work.