简体   繁体   English

如何在颤振中创建超链接图标?

[英]How to create hyperlink icon in flutter?

I want to create a hyperlink in Icon:我想在 Icon 中创建一个超链接:

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

How can we achieve this?我们怎样才能做到这一点?

Error:错误:

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

Here is the solution, thanks to: Pavel这是解决方案,感谢: 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';
  }
 }
)

The problem is that you have added dependency in pubspec.yaml and then just hot-reloaded the app.问题是您在pubspec.yaml添加了依赖pubspec.yaml ,然后只是热重载了应用程序。 Native dependencies aren't added during hot reload.热重载期间不会添加本机依赖项。 MissingPluginException means exactly that native (Android/iOS) plugin implementation is missed. MissingPluginException意味着错过了原生 (Android/iOS) 插件实现。

You should fully stop and start the app again您应该完全停止并重新启动应用程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM