Flutter 拨打电话和跳转网页
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                Flutter 拨打电话和跳转网页
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                首先需要一如庫 url_launcher? 如下
?
具體寫法如下
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("打開連接"),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 如果幫助了你希望給個免費的star
總結
以上是生活随笔為你收集整理的Flutter 拨打电话和跳转网页的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 友开头的成语有哪些啊?
- 下一篇: Android studio 文件包名连
