launchURLInWebViewOrBrowser static method

Future<void> launchURLInWebViewOrBrowser(
  1. BuildContext context,
  2. String url, {
  3. LaunchMode? mode,
})

Launches the URL in a WebView if it's an OFF link or an external browser.

Implementation

static Future<void> launchURLInWebViewOrBrowser(
  BuildContext context,
  String url, {
  LaunchMode? mode,
}) async {
  if (url.startsWith(
    RegExp(
      r'http(s)?://[a-z\-]*.open(food|beauty|products|petfood)facts.(net|org)',
    ),
  )) {
    AppNavigator.of(context).push(AppRoutes.EXTERNAL_WEBVIEW(url));
  } else {
    return launchURL(url, mode: mode);
  }
}