当我调用 launchUrl (url_launcher 6.2.2) 它不起作用或不出色。
我想用链接打开goole驱动器。
final Uri url = Uri.parse("googel drive link share all people have");
bool res = await launchUrl(url);
if (!res) {throw Exception('Could not launch url');}
试试这个:
import 'package:url_launcher/url_launcher.dart';
final String googleDriveLink = "https://drive.google.com/your-link-here";
final Uri url = Uri.parse(googleDriveLink);
try {
bool launched = await launch(url.toString());
if (!launched) {
throw 'Could not launch $url';
}
} catch (e) {
throw 'Error launching URL: $e';
}
确保您已将
url_launcher
软件包添加到您的 pubspec.yaml
文件中:
dependencies:
url_launcher: ^6.2.2