【问题标题】:the fileUrl file does not exists in flutter颤振中不存在fileUrl文件
【发布时间】:2022-01-18 05:32:00
【问题描述】:

想在浏览器中打开文件 url,但我面临的问题是 文件 fileUrl 不存在。但是当我将该网址粘贴到浏览器中时,它会打开该文件。

 final msg = await OpenFile.open(message.uri);
  log("msg result =${msg.message.toString()}");

输出: msg 结果 = 文件 fileurl 不存在

网址是:Url

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    如果您想在浏览器中打开文件,请使用 url_launcher 包:url_launcher

    _launchURL(String url) async {
      if (await canLaunch(url)) {
        await launch(url);
      } else {
        throw 'Could not launch $url';
      }
    }
    

    【讨论】:

    • 但首先我使用了这个 url 启动器,但它没有打开。
    • 查看message.uri是否有值?然后你在你的项目中添加了包?并将名称空间放在您的小部件中?如果您正确地完成了这些步骤,它一定可以工作。
    • 是的,我做到了,但可能是代码中的一些问题
    • 我编辑了答案,我使用了异步方法打开浏览器,可能是因为问题不是异步的
    猜你喜欢
    • 2021-07-04
    • 2019-06-20
    • 2019-06-21
    • 1970-01-01
    • 1970-01-01
    • 2021-01-06
    • 2021-02-25
    • 2019-05-25
    • 1970-01-01
    相关资源
    最近更新 更多