1 需求
2 代码实现
import 'package:Flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
void main() {
runApp(MyApp1());
}
class MyApp1 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'open url',home: Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method,and use it to set our appbar title.
title: Text('hello Flutter'),),body: Center(
child: RaisedButton(
onpressed: () {
const url = 'https://www.baidu.com';
launch(url);
},child: Text('open baidu'),);
}
}