![](/img/trans.png)
[英]ERROR:flutter/runtime/dart_vm_initializer.cc(41) Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' for json file ,flutter
[英]ERROR:flutter/runtime/dart_vm_initializer.cc(41) on url_launcher
在我的 android studio 模擬器上運行調試后,我使用 HTTP 啟動器並在我的控制台日志中發現了這個錯誤:
[錯誤:flutter/runtime/dart_vm_initializer.cc(41)] 未處理的異常:MissingPluginException(未在通道 plugins.flutter.io/url_launcher_android 上找到方法啟動的實現)
這是它拋出錯誤的代碼:
Future<void> _launchMap() async {
final url = widget.website;
var uri = Uri.parse(url);
if (!await launchUrl(uri)) {
throw 'Could not launch';
}
}
這是我的安卓清單:
<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>
我使用最新的 flutter 版本並且我已經按照https://pub.dev/packages/url_launcher中的指南進行操作,但它仍然無法從我的 API 中定向我想要的鏈接
如果您使用的是熱重啟或熱重載,則無法解決問題。 由於 Flutter 必須將插件依賴項注入應用程序的特定平台部分,因此熱重啟/熱重載不足以觸發注入。 檢查此問題以獲取更多信息。
關閉應用程序並執行flutter run
命令。
試試下面的代碼:
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.