[英]ERROR:flutter/runtime/dart_vm_initializer.cc(41) on url_launcher
I use HTTP launcher and found this error on my console log after I run debug on my android studio emulator:在我的 android studio 模拟器上运行调试后,我使用 HTTP 启动器并在我的控制台日志中发现了这个错误:
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher_android)
[错误:flutter/runtime/dart_vm_initializer.cc(41)] 未处理的异常:MissingPluginException(未在通道 plugins.flutter.io/url_launcher_android 上找到方法启动的实现)
This is the code where it throw error:这是它抛出错误的代码:
Future<void> _launchMap() async {
final url = widget.website;
var uri = Uri.parse(url);
if (!await launchUrl(uri)) {
throw 'Could not launch';
}
}
this is my android manifest:这是我的安卓清单:
<queries>
<!-- If your app checks for call support -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="tel" />
</intent>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
I use the newest flutter version and I already follow the guide from https://pub.dev/packages/url_launcher , but it still can't direct the link that I want from my API我使用最新的 flutter 版本并且我已经按照https://pub.dev/packages/url_launcher中的指南进行操作,但它仍然无法从我的 API 中定向我想要的链接
If you are using hot restart or hot reload, it won't do the trick.如果您使用的是热重启或热重载,则无法解决问题。 Since Flutter has to inject plugin dependencies into the platform-specific parts of your app, hot restart/hot reload is not enough to trigger the injection.
由于 Flutter 必须将插件依赖项注入应用程序的特定平台部分,因此热重启/热重载不足以触发注入。 Check this issue for more.
检查此问题以获取更多信息。
Close the app and execute flutter run
command.关闭应用程序并执行
flutter run
命令。
Try the following code:试试下面的代码:
Future<void> _launchMap() async {
final url = widget.website;
var uri = Uri.parse(url);
if (await canLaunchUrl(url)) {
await launchUrl(url);
} else {
throw 'Could not launch $url';
}}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.