在Flutter Web开发中,有时候需要跳转到网站, 可以通过url_launcher这个第三方库实现.
代码示例
首先引入依赖 url_launcher: ^5.4.2
业务代码:
import 'package:url_launcher/url_launcher.dart';
//定义方法
_launchURL(url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}
//跳转
_launchURL("https://www.baidu.com");
點擊查看更多內容
1人點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦