【问题标题】:The argument type 'String' can't be assigned to the parameter type 'Source'参数类型\'String\'不能分配给参数类型\'Source\'
【发布时间】:2022-08-22 14:16:25
【问题描述】:

参数类型 \'String\' 不能分配给参数类型 \'Source\'。 在该代码中,url 用红色下划线划线

  playMusic() async {
    await audioPlayer.play(url);
  }
  • 您能否包含更多代码和详细信息您正在使用什么以及出了什么问题

标签: flutter dart


【解决方案1】:

尝试像下面这样使用它

因为您传递了String 值但函数需要url 所以Uri.parse 将帮助您将String 转换为url

await audioPlayer.play(Uri.parse(url));

【讨论】:

    猜你喜欢
    • 2023-01-23
    • 2021-10-02
    • 2021-10-06
    • 2020-04-15
    • 2021-06-19
    • 2021-08-19
    • 2021-11-14
    • 1970-01-01
    相关资源
    最近更新 更多