Skip to content
Blog

Launching URLs in Flutter: url_launcher Patterns Across Platforms

Open https, mailto, tel, and sms links from Flutter reliably across Android, iOS, desktop, and web with url_launcher.

Published on • November 2, 2026

AI Assistant

Handing a link to the OS — a support page, an email draft, a phone call — is app plumbing that breaks silently per platform, and url_launcher (6.3.3, a Flutter Favorite) covers https, mailto, tel, sms, and file schemes through a federated plugin set: Android (SDK 24+), iOS (13.0+), Linux, macOS, Web, and Windows 10+ (pub.dev).

Launching with launchUrl and canLaunchUrl

launchUrl returns a bool (false = nothing handled it); canLaunchUrl probes for a handler:

Future<void> openDocs() async {
  final uri = Uri.parse('https://blog.redlinesoft.net');
  if (await canLaunchUrl(uri)) {
    await launchUrl(uri, mode: LaunchMode.inAppBrowserView);
  }
}

Declaring Schemes on iOS and Android

Both mobile platforms hide non-web handlers until you declare them. On iOS, list every scheme you probe in Info.plist under LSApplicationQueriesSchemes (mailto, tel, sms, …). On Android 11+ (API 30) package visibility requires matching <queries> entries in AndroidManifest.xml — skip either and canLaunchUrl returns false for links that would open fine:

<queries>
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="https" />
  </intent>
</queries>

Choosing a LaunchMode

LaunchMode controls where the URL opens: platformDefault, inAppBrowserView (Custom Tab / SFSafariViewController), or externalApplication (standalone browser or another app). Guard LaunchMode.inAppWebView with supportsLaunchMode too — web views only exist on some platforms:

final external = await supportsLaunchMode(LaunchMode.externalApplication);
await launchUrl(
  Uri.parse(url),
  mode: external ? LaunchMode.externalApplication : LaunchMode.platformDefault,
);

Encoding Non-HTTP URIs Correctly

Uri.parse does not percent-encode spaces or &, and uri.queryParameters is unreliable for non-HTTP schemes, so hand-built mailto: links fail quietly. Build them with the Uri constructor (or the documented encodeQueryParameters helper for raw strings):

final uri = Uri(scheme: 'mailto', path: 'support@redlinesoft.net',
    queryParameters: {'subject': 'Bug in 1.4.0', 'body': 'Steps to reproduce...'});
await launchUrl(uri, mode: LaunchMode.externalApplication);

Failure Handling: canLaunchUrl Can Lie

canLaunchUrl can return false while launchUrl would succeed, because visibility rules and the launch probe differ — so attempt the launch and fall back:

try {
  if (await launchUrl(uri, mode: LaunchMode.externalApplication)) return;
} on PlatformException {
  // no handler, or package visibility blocked the query
}
await launchUrl(uri, mode: LaunchMode.inAppBrowserView);

Gotchas and Best Practices

  • On web, start the launch inside the user gesture that triggered it — an await beforehand can break popup rules.
  • Handle false from launchUrl with visible feedback (a SnackBar), never an unhandled exception.
  • Emulators lack handlers for sms: and file:; verify those flows on real hardware.

Declare your schemes, build URIs with the Uri constructor, and treat “try to launch, then fall back” as the pattern that survives every platform quirk.