url_launcher是用于在移动平台中启动URL的Flutter插件,适用于IOS和Android平台。他可以打开网页,发送邮件,还可以拨打电话。

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

引入依赖

pubspec.yaml文件里注册依赖,并保存下载包。请注意使用最新版。

url_launcher: ^5.1.

在需要使用的页面在使用import引入具体的url_launcher包。

import 'package:url_launcher/url_launcher.dart';

支持的URL方案

方案 Action
http:<URL>https:<URL> 例如 http://flutter.dev 在默认浏览器中打开URL

mailto:<email address>?subject=<subject>&body=<body>

例如

mailto:smith@example.org?subject=News&body=New%20plugin

在默认电子邮件应用中创建电子邮件
tel:<phone number>, 例如 tel:+1 555 010 999 拨打电话以使用默认电话应用程序
sms:<phone number>, 例如 sms:5550101234 使用默认消息传递应用程序发送SMS消息 

代码示例:

    String url = 'tel:12306' ;
if(await canLaunch(url)){
await launch(url);
}else{
throw 'url不能进行访问,异常。';
} //或者 String url = 'https://www.baidu.com';
if(await canLaunch(url)){
await launch(url);
}else{
throw 'url不能进行访问,异常。';
}

最新文章

  1. es6 ajax
  2. C++ 之引用
  3. XE6移动开发环境搭建之IOS篇(4):VMware9里安装Mac OSX 10.8(有图有真相)
  4. SWFUpload使用指南
  5. iOS开源 框架
  6. Traits技法
  7. 出错:Failed to convert property value of type &#39;org.apache.ibatis.session.defaults.DefaultSqlSessionFactory&#39; to required type &#39;java.lang.String&#39; for property &#39;sqlSessionFactoryBeanName&#39;;
  8. c#串口测试
  9. CentOS7 安装中文输入法
  10. hdu6133 Army Formations 线段树合并
  11. 【随笔】借鉴 &amp; KPI式设计
  12. 存储空间消耗磁盘比较 int varchar date
  13. 浙江省赛 ZOJ4029
  14. hdu6444 Neko&#39;s Loop
  15. linux\mac 日常入门命令行使用——搜索文件\文件夹
  16. WPF开发的彩票程序(练手好例子)
  17. 手动抠下的wordpress登录页面样式
  18. 关于Unity的坐标系
  19. Spring整合Mybatis SQL语句的输出
  20. 6、perl创建模块(Exporter)及路径 引用 嵌套 查询模块

热门文章

  1. ZZNUOJ-2155-单身man集合-【标程做法:数位DP-1-10^8,提前暴力打表法: 砍时间复杂度到10^5】
  2. 大数据之路week02--day03 Map集合、Collections工具类的用法
  3. webpack 配置react脚手架
  4. selenium怎样避免被服务器检测
  5. 注册emf package并读取EMF文件
  6. P4178 Tree 点分治
  7. sql server 知识整理 isnull函数()
  8. sqlserver中产生随机字符,随机数
  9. Test 1 T2 B 线段树合并
  10. Visual Studio Code:中文乱码