url_launcher一键拨打电话和链接插件

插件地址:https://github.com/flutter/plugins/tree/master/packages/url_launcher


推荐使用的url插件,很方便,还可以一键打开发送邮箱的界面,还有拨打电话界面,发送短信等。


Scheme Action
http:<URL> , https:<URL>, e.g. http://flutter.io Open URL in the default browser
mailto:<email address>?subject=<subject>&body=<body>, e.g. mailto:smith@example.org?subject=News&body=New%20plugin Create email to in the default email app
tel:<phone number>, e.g. tel:+1 555 010 999 Make a phone call to using the default phone app
sms:<phone number>, e.g. sms:5550101234 Send an SMS message to using the default messaging app

如果想拨打电话界面就直接写个:

url = 'tel:+1 555 010 999';//+1 555 010 999是电话号码,
 // 记得一定要加冒号:,不然出错


直接样品:
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(Scaffold(
    body: Center(
      child: RaisedButton(
        onPressed: _launchURL,
        child: Text('Show Flutter homepage'),
      ),
    ),
  ));
}

_launchURL() async {
  const url = 'https://flutter.io';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}
本博客所有文章如无特别注明均为原创。作者:flutter教程网复制或转载请以超链接形式注明转自 Flutter教程网
原文地址《url_launcher一键拨打电话和链接插件
分享到:更多

相关推荐



Flutter教程网 官方QQ群:874592746

扫描下面二维码 加入Flutter教程网微信群:


关注公众号“Flutter前线”,各种Flutter项目实战经验技巧,干活知识,Flutter面试题答案,等你来领取。


发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(1)

I have noticed you don't monetize flutterj.com, don't waste your traffic,
you can earn extra cash every month with new monetization method.
This is the best adsense alternative for any type of website (they
approve all sites), for more details simply search in gooogle: murgrabia's tools
MO 11个月前 (2019-08-25) 回复