launchURL static method
void
launchURL(})
Implementation
static void launchURL(String url, {bool openInApp = true, bool clearCache = false, bool clearCookies = false, bool sameTab = false}) async {
AppConfig.logger.d('Launching: $url - openInApp: $openInApp');
try {
if (await canLaunchUrl(Uri.parse(url))) {
if(openInApp && UrlUtilities.isExternalDomain(url)) {
openInApp = false;
}
if (kIsWeb && sameTab) {
// Si estás en la web, abre en la misma pestaña o en una nueva
// html.window.location.href = url; // Esto abrirá en la misma pestaña
} else {
if(clearCache) await clearWebViewCache();
if(clearCookies) await clearWebViewCookies();
await launchUrl(Uri.parse(url),
mode: openInApp ? LaunchMode.inAppWebView : LaunchMode.externalApplication,
);
}
} else {
AppConfig.logger.i('Could not launch $url');
}
} catch(e) {
AppConfig.logger.e(e.toString());
}
}