flutter 无法打开启动 Url google Drive

问题描述 投票:0回答:1

当我调用 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');}
flutter kotlin dart url google-drive-api
1个回答
0
投票

试试这个:

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
© www.soinside.com 2019 - 2024. All rights reserved.