launchUrl method
Passes url
to the underlying platform for handling.
Returns true
if the given url
was successfully launched.
Implementation
@override
Future<bool> launchUrl(String url, LaunchOptions options) async {
final bool inApp;
switch (options.mode) {
case PreferredLaunchMode.inAppWebView:
case PreferredLaunchMode.inAppBrowserView:
// The iOS implementation doesn't distinguish between these two modes;
// both are treated as inAppBrowserView.
inApp = true;
case PreferredLaunchMode.externalApplication:
case PreferredLaunchMode.externalNonBrowserApplication:
inApp = false;
case PreferredLaunchMode.platformDefault:
// Intentionally treat any new values as platformDefault; support for any
// new mode requires intentional opt-in, otherwise falling back is the
// documented behavior.
// ignore: no_default_cases
default:
// By default, open web URLs in the application.
inApp = url.startsWith('http:') || url.startsWith('https:');
break;
}
if (inApp) {
return _mapInAppLoadResult(
await _hostApi.openUrlInSafariViewController(url),
url: url);
} else {
return _mapLaunchResult(await _hostApi.launchUrl(url,
options.mode == PreferredLaunchMode.externalNonBrowserApplication));
}
}