最近在fluttergo的issue中看到一条信息.笔者去pub库中简单的查了一个这个库的使用方法, 这个库的文档延续了google简约的风格. 查阅了baidu. google后也没有发现什么有意义的文档. 除了将英文翻译转化成中文, 就没有直接伸手党能够用的东西. 因此笔者亲自进行尝试.html
求问flutter如何打开第三方app,,我想flutter一件打开淘宝app,可是我发现我,我没法打开,我经过搜索引擎拿到的方法都是 url_launcher这个插件,这个插件,好像没法打开淘宝,,,,我目前的作法是 拿到了 手机淘宝app在ios的app Store连接,用url_launcher打开这个连接, 而后会跳转到app Store,app store在一建打开淘宝,,可是安卓我就没辙了,,求大神们,提供一下 flutter如何一键打开淘宝app fluttergo issueios
你们能够自行参考官方文档: 简约的文档git
将包的信息添加到pubspec.yaml:github
dependencies:
url_launcher: ^5.1.3
复制代码
使用方法比较简单, 只要为某个按钮增长点击事件, 调用launch便可chrome
import 'package:url_launcher/url_launcher.dart';
...
_launchURL() async {
const url = 'xxx'; // 这个xx就是唤起三方应用的重要因素
if (await canLaunch(url)) { // 判断当前手机是否安装某app. 可否正常跳转
await launch(url);
} else {
throw 'Could not launch $url';
}
}
@override
Widget build(BuildContext context) {
...
RaisedButton(
onPressed: _launchURL,
child: Text("打开三方应用"),
),
...
}
复制代码
在笔者按照官方的说明一步一步的调用的时候. 在点击按钮的时候模拟器居然报错了. 报错的信息以下:浏览器
Unhandled Exception: MissingPluginException(No implementation found for method launch on channel)bash
这个错误显示的是Plugin的方法没有找到,也许是Plugin没有注册成功。 拿到这条消息的时候, 咱们也是一脸蒙蔽的. 在尝试了如下二种方案后app成功运行微信
以上二个方案, 不知道是哪一个解决的这个问题. 我是挨个作了一遍后成功运行.app
使用 googlechrome: 打开谷歌浏览器 async
使用 tel: 拨打电话
在flutter打开三方应用, 除了官方文档中举例外. 咱们一般须要打开相似于 淘宝,支付宝, 微信, 京东等app, 打开这一类的app须要知道对应 app的url schema, 便可顺滑的打开三方app
这里以taobao作举例, 淘宝的schema是 taobao:
_launchURL() async {
String url ="taobao://item.taobao.com/item.html?id=41700658839";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
复制代码
最后附上一个网上搜来schema的集合, 原文地址
QQ: mqq://
微信: weixin://
京东: openapp.jdmoble://
淘宝: taobao://
美团: imeituan://
点评: dianping://
1号店: wccbyihaodian://
支付宝: alipay://
微博: sinaweibo://
腾讯微博: TencentWeibo://
weico微博: weico://
知乎: zhihu://
豆瓣fm: doubanradio://
网易公开课: ntesopen://
Chrome: googlechrome://
QQ浏览器: mqqbrowser://
uc浏览器: ucbrowser://
搜狗浏览器: SogouMSE://
百度地图: baidumap:// bdmap://
优酷: youku://
人人: renren://
我查查: wcc://
有道词典: yddictproapp://
微盘: sinavdisk://
名片全能王: camcard://
复制代码