【问题标题】:How to resolve could not launch Error in Url launcher如何解决 Url 启动器中的无法启动错误
【发布时间】:2021-05-27 06:37:02
【问题描述】:

我正在尝试在 Google Pixel API 30 Emulator 上打开一个链接,但不断出现错误。已尝试清理干净、重新启动的应用程序。

依赖:-

url_launcher: ^6.0.3

代码:-

  InkWell(
onTap:() => _launchURL("https://google.com"),
child: Image.asset("assets/images/googleIcon.jpg")
),

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

}

错误:-

   Unhandled Exception: Could not launch https://google.com

【问题讨论】:

标签: flutter dart url-launcher


【解决方案1】:

添加一个 URI 类,因为 url_launcher 建议将 URL 编码为 URI。 Link to Doc

final Uri _faireGitHubUri = Uri.https('google.com', '/');

    InkWell(
onTap:() => _launchURL(_websiteUri.toString()),
child: Image.asset("assets/images/googleIcon.jpg")
),

【讨论】:

    猜你喜欢
    • 2017-06-18
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    • 2019-07-30
    • 2021-08-06
    • 2014-07-01
    • 2021-10-08
    • 2019-02-08
    相关资源
    最近更新 更多