Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Main file for url_launcher_example
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/material.dart';
void main() => runApp(UrlLauncherExample());
class UrlLauncherExample extends StatelessWidget {
static const String _title = 'URL Launcher Example';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: LaunchButton(),
),
);
}
}
class LaunchButton extends StatelessWidget {
LaunchButton({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: RaisedButton(
onPressed: _launch,
child: Text(
'Launch!',
style: TextStyle(fontSize: 20),
),
),
);
}
void _launch() {
launch('https://www.google.com');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.