Flutter之点击按钮打开百度链接
生活随笔
收集整理的這篇文章主要介紹了
Flutter之点击按钮打开百度链接
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 需求
點擊按鈕,打開百度鏈接
?
?
?
?
?
?
?
2 代碼實現
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart';void main() {runApp(MyApp1()); }class MyApp1 extends StatelessWidget {@overrideWidget 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'),),),),);} }?
?
?
?
?
?
?
?
3 運行效果
總結
以上是生活随笔為你收集整理的Flutter之点击按钮打开百度链接的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Flutter之运行提示Could no
- 下一篇: Flutter之基本数据类型测试