【问题标题】:How to create hyperlink icon in flutter?如何在颤振中创建超链接图标?
【发布时间】:2020-04-18 13:37:10
【问题描述】:

我想在 Icon 中创建一个超链接:

IconButton(
  icon: Icon(Icons.ac_unit,),
  onPressed: ()=>launch('https://github.com/himanshusharma89'),
)

我们怎样才能做到这一点?

错误:

Exception has occurred.
MissingPluginException (MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher))

【问题讨论】:

  • 当前代码有什么问题?
  • Exception has occurred. MissingPluginException (MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher))
  • 你可以看到它可以帮助你:stackoverflow.com/a/55129517
  • 请在您的问题中添加例外文本
  • 您似乎在 pubspec.yaml 中添加了依赖项,然后热重载了该应用程序。问题是在热重载期间没有添加本机依赖项。您应该完全停止并重新启动应用程序

标签: android flutter dart icons


【解决方案1】:

这里是解决方案,感谢:Pavel

IconButton(
 icon: Icon(Icons.ac_unit,),
 onPressed: () async {
  const url = 'https://github.com/himanshusharma89';
  if (await canLaunch(url)) {
   await launch(url);
  } else {
   throw 'Could not launch $url';
  }
 }
)

【讨论】:

    【解决方案2】:

    问题是您在pubspec.yaml 中添加了依赖项,然后只是热重载了应用程序。热重载期间不会添加本机依赖项。 MissingPluginException 意味着错过了原生(Android/iOS)插件实现。

    您应该完全停止并重新启动应用程序

    【讨论】:

      猜你喜欢
      • 2021-12-26
      • 1970-01-01
      • 2011-04-15
      • 2021-04-21
      • 2021-10-12
      • 2021-08-07
      • 2016-11-28
      • 2016-10-16
      • 2021-07-07
      相关资源
      最近更新 更多