openLink static method

void openLink(
  1. String url
)

打开链接或跳转到指定App

参数: url 必填,目标链接(如"https://www.apple.com")。

示例:

AppUtil.openLink('https://www.apple.com');

返回: 无返回值,打开失败则在日志输出异常

Implementation

static void openLink(String url) async {
  if (GetUtils.isURL(url)) {
    try {
      final uri = Uri.parse(url);
      if (await canLaunchUrl(uri)) {
        await launchUrl(uri);
      } else {
        throw 'Could not launch $url';
      }
    } catch (e) {
      Logger.log('ppkits openLink error: $e');
    }
  }
}