我正在使用Dio进行调用,该调用使用地图构造函数发送一些查询参数
response = await Dio().get(url, queryParameters: {
"apikey": publicKey,
"hash": hash,
"ts": timestamp,
"nameStartsWith": searchTerm
});
一切正常,但是当尝试发送int值时,Dio抛出错误
response = await Dio().get(url, queryParameters: {
"apikey": publicKey,
"hash": hash,
"ts": timestamp,
"nameStartsWith": searchTerm,
"page" : 10
});
类型'int'不是'可迭代<动态>'#0
类型的子类型
而且我不能只将int值转换为字符串,因为api正在使用int类型。
有帮助吗?
答案 0 :(得分:1)
URL中没有int类型,因此在查询参数中也没有。
URL只能是字符串。
只需将其转换为String即可。