Flutter - launchUrl:当我执行flutter launchUrl(url)时,我打算导航到的URL和实际在web中打开的URL是不同的

问题描述 投票:0回答:1

使用 launchUrl 调用 URL 时,前一两次它会导航到正确的 URL,但此后,它会卡在特定 URL 上。下面是我使用的代码。

 String getReportUrl() {
    final String formattedDate =
        DateFormat('yyyy-MM-dd').format(strToDateTime(errorDate));
    print(
        "CALL https://www.aaa.net/bbb/ccc-ddd?store=${data.store}&startDate=$formattedDate&endDate=$formattedDate");
    return "https://www.aaa.net/bbb/ccc-ddd?store=${data.store}&startDate=$formattedDate&endDate=$formattedDate";
  }

  void _clickURL() async {
    Uri url = Uri.parse(getReportUrl());
    if (await canLaunchUrl(url)) {
      await launchUrl(url);
    } else {
      throw "Could not launch $url";
    }
  }

为什么会出现这种情况,请提供解决方案。

我检查了 getReportUrl() 中解析 URL 是否存在问题,但一切正常。另外,我在通话期间记录了 URL,并且日志显示了我想要导航到的正确 URL。

android ios flutter web webview
1个回答
0
投票

经检查,发现Flutter应用没有问题;问题出在我尝试访问的网站的缓存策略上。

© www.soinside.com 2019 - 2024. All rights reserved.