url_launcher is an official Flutter plugin for launching a URL in iOS, Android, web, Windows, macOS, and Linux.
List of common schemes supported on mobile:
http:<URL> , https:<URL> , e.g. https://www.tldevtech.com | Open the URL in the default browser |
mailto:<email address>?subject=<subject>&body=<body> , e.g. mailto:[email protected]?subject=Contact&body=New%20plugin | Create email to |
tel:<phone number> , e.g. tel:+1 555 111 222 | Make a phone call to |
sms:<phone number> , e.g. sms:5552223334 | Send an SMS message to |
Despite its support for the web, you can’t use it properly yet in Flutter for the Web in the beta channel. We need to detect the current platform and provide a suitable solution.
Required packages:
import 'dart:html' as html; import 'dart:io'; import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart';
Create a function to open an URL based on the current platform

void _launchUrl(String url) async { if (kIsWeb) { // web html.document.window.location.href = url; } else if (Platform.isAndroid || Platform.isIOS || Platform.isFushsia || Platform.isWindows) { // others if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } else { // the rest throw new Exception('Unsupported platform'); } }