[英]Error while using URL Launcher in Flutter
onTap: () async {
final url = products[index].url;
if (!await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
Error:错误:
I/UrlLauncher(20613): component name for https://www.crucial.in/products/memory/desktop-dram is {com.android.chrome/com.google.android.apps.chrome.IntentDispatcher}
E/flutter (20613): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Could not launch https://www.crucial.in/products/memory/desktop-dram
E/flutter (20613): #0 HomeScreen.build.<anonymous closure>.<anonymous closure>
package:crucial/screens/home_screen.dart:52
E/flutter (20613): <asynchronous suspension>
Add this to your android manifest file:将此添加到您的 android 清单文件中:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
And use this:并使用这个:
Future<void>_launchURL(String link) async {
if (await canLaunchUrl(Uri.parse(link))) {
await launchUrl(Uri.parse(link));
} else {
throw 'Could not launch $link';
}
}
Works for me适合我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.