openLink static method

Future<bool> openLink(
  1. String link, {
  2. String? href,
  3. String title = "",
  4. bool preferNonBrowserApp = false,
})

Implementation

static Future<bool> openLink(
  String link, {
  String? href,
  String title = "",
  bool preferNonBrowserApp = false,
}) async {
  try {
    String urlString = GetUtils.isURL(link) ? link : (href ?? "");
    if (!urlString.contains("https://") && !urlString.contains("http://")) {
      urlString = "https://$urlString";
    }
    Uri url = Uri.parse(urlString);
    return await launchUrl(
      url,
      mode: preferNonBrowserApp
          ? LaunchMode.externalNonBrowserApplication
          : LaunchMode.externalApplication,
    );
  } catch (e) {
    return false;
  }
}