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> { @override Widget build(BuildContext context) { return Container( color: Colors.white, child: ListView( children: [ textButtonItem('打开外部浏览器', "https://cflutter.com"), textButtonItem('拨打电话', "tel:10086"), textButtonItem('发送短信', "sms:10086"), textButtonItem('打开微信', "weixin://"), textButtonItem('打开支付宝', 'alipays://'), textButtonItem('打开淘宝', 'taobao://'), textButtonItem( '发送邮件', "mailto:luckly@gmail.com?subject=Test&body=测试"), // 协议格式: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'; } }, ); } }
打开其它应用时,都是改变相应的url协议地址即可,跳转原理参照原生开发使用的url scheme,常用的如下: