Flutter Dio 不接受 int 值作为查询参数

ces*_*cas 5 dart flutter

我正在使用 Dio 进行调用,使用 map 构造函数发送一些查询参数

  response = await Dio().get(url, queryParameters: {
    "apikey": publicKey,
    "hash": hash,
    "ts": timestamp,
    "nameStartsWith": searchTerm
  });
Run Code Online (Sandbox Code Playgroud)

一切正常,但是当尝试发送 int 值时,Dio 抛出错误

  response = await Dio().get(url, queryParameters: {
    "apikey": publicKey,
    "hash": hash,
    "ts": timestamp,
    "nameStartsWith": searchTerm,
    "page" : 10
  });
Run Code Online (Sandbox Code Playgroud)

'int' 类型不是 'Iterable < dynamic > '#0 类型的子类型

而且我不能只是将 int 值转换为字符串,因为 api 正在使用 int 类型。

有什么帮助吗?

Gün*_*uer 6

URL 中没有 int 类型,因此在查询参数中也没有。
URL 只能是字符串。

只需将其转换为 String 即可完成。