Flutter 拨打电话和跳转网页
生活随笔
收集整理的這篇文章主要介紹了
Flutter 拨打电话和跳转网页
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
首先需要一如庫(kù) url_launcher? 如下
?
具體寫(xiě)法如下
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
class LinkViewShow extends StatelessWidget{@overrideWidget build(BuildContext context) {return new MaterialApp(home: new Scaffold(appBar: AppBar(title: new Text("布局"),backgroundColor: Colors.amber,),body: new LinkView()),);}
}
class LinkView extends StatefulWidget{@overrideState<StatefulWidget> createState() {// TODO: implement createStatereturn new LinkViewState ();}
}
class LinkViewState extends State<LinkView>{@overrideWidget build(BuildContext context) {return new Column(children: <Widget>[RaisedButton(child: Text("打開(kāi)連接"),onPressed: _launchURL,),RaisedButton(child: Text("撥打電話"),onPressed: _launchPhone,)],);}
}_launchPhone() async {const url = 'tel:17601290637';if (await canLaunch(url)) {await launch(url);} else {throw 'Could not launch $url';}
}
_launchURL() async{const url = 'https://github.com';if (await canLaunch(url)) {await launch(url);} else {throw 'Could not launch $url';}
}
?
?
效果地址? ? ? ? ? ? ?github 如果幫助了你希望給個(gè)免費(fèi)的star
總結(jié)
以上是生活随笔為你收集整理的Flutter 拨打电话和跳转网页的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 友开头的成语有哪些啊?
- 下一篇: Android studio 文件包名连