To open a web browser with a URL in Flutter, you can use the url_launcher package. Here’s how you can do it:

1. Add url_launcher to pubspec.yaml:

dependencies:
 url_launcher: ^6.1.14

2. Import the package:

import 'package:url_launcher/url_launcher.dart';

3. Launch URL:

Future _launchURL() async {
 final Uri url = Uri.parse('https://flutter.dev');
 if (await canLaunchUrl(url)) {
   await launchUrl(url);
 } else {
   throw 'Could not launch $url';
 }
}

4. Call the function:

ElevatedButton(
onPressed: _launchURL,
child: Text('Open Flutter Website'),
)

iOS Configuration (if needed):

Add this to your Info.plist:

LSApplicationQueriesSchemes

https
http

Android Configuration (if needed):

Add this to AndroidManifest.xml:







Output :

output

Support On Demand!

Flutter

Related Q&A