Flutter 插件url_launcher简介及使用,打开外部浏览器,拨打电话,发送短信,打开微信,支付宝,qq等
生活随笔
收集整理的這篇文章主要介紹了
Flutter 插件url_launcher简介及使用,打开外部浏览器,拨打电话,发送短信,打开微信,支付宝,qq等
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
url_launcher
插件名稱:url_launcher
使用Demo
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart';class Url_launcherPage extends StatefulWidget {@override_Url_launcherPageState createState() => _Url_launcherPageState(); }class _Url_launcherPageState extends State<Url_launcherPage> {@overrideWidget build(BuildContext context) {return Container(color: Colors.white,child: ListView(children: [textButtonItem('打開外部瀏覽器', "https://cflutter.com"),textButtonItem('撥打電話', "tel:10086"),textButtonItem('發(fā)送短信', "sms:10086"),textButtonItem('打開微信', "weixin://"),textButtonItem('打開支付寶', 'alipays://'),textButtonItem('打開淘寶', 'taobao://'),textButtonItem('發(fā)送郵件', "mailto:luckly@gmail.com?subject=Test&body=測試"),// 協(xié)議格式:mailto:<email address>?subject=<subject>&body=<body>],),);}Widget textButtonItem(String title, String urlLink) {return TextButton(child: Text(title),onPressed: () async {var url = urlLink;if (await canLaunch(url)) {await launch(url);} else {throw 'Could not launch $url';}},);} }打開其它應(yīng)用時,都是改變相應(yīng)的url協(xié)議地址即可,跳轉(zhuǎn)原理參照原生開發(fā)使用的url scheme,常用的如下:
QQ: mqq:// 微信: weixin:// 京東: openapp.jdmoble:// 測試了,好像不行 淘寶: taobao:// 美團: imeituan:// 點評: dianping:// 1號店: wccbyihaodian:// 支付寶: alipay:// 微博: sinaweibo:// 騰訊微博: TencentWeibo:// weico微博: weico:// 知乎: zhihu:// 豆瓣fm: doubanradio:// 網(wǎng)易公開課: ntesopen:// Chrome: googlechrome:// QQ瀏覽器: mqqbrowser:// uc瀏覽器: ucbrowser:// 搜狗瀏覽器: SogouMSE:// 百度地圖: baidumap:// bdmap:// 優(yōu)酷: youku:// 人人: renren:// 我查查: wcc:// 有道詞典: yddictproapp:// 微盤: sinavdisk:// 名片全能王: camcard://總結(jié)
以上是生活随笔為你收集整理的Flutter 插件url_launcher简介及使用,打开外部浏览器,拨打电话,发送短信,打开微信,支付宝,qq等的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: dart语法中list相关详解
- 下一篇: 如何设置Flutter