如果走完安裝流程后運行Flutter時提示:
export LANG=en_US.UTF-8 Error running pod install
需要在配置文件.bash_profile中加上:
export LANG=en_US.UTF-8
1.flutter開發者網站下載url_launcher插件 下載鏈接
2.在 pubspec.yaml 文件中添加依賴:
dependencies: url_launcher: ^5.0.3
3.安裝:
flutter pub get
4.導入:
import 'package:url_launcher/url_launcher.dart';
5.使用:
一:打開瀏覽器
_launchURL、_openMapApp為自定義方法名 可以根據自己的場景自定義名稱
_launchURL() async { const url = 'https://flutter.io'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } }
資源搜索網站大全 https://www.renrenfan.com.cn 廣州VI設計公司https://www.houdianzi.com
二:打開外部APP
打開外部APP 需要外部APP提供跳轉的schema
_openMapApp() async { const url = 'geo:52.32,4.917'; //APP提供的schema if (await canLaunch(url)) { await (launch(url)); //安卓中打開 } else { //iOS中打開 const url = 'http://maps.apple.com/?ll=52.32,4.917'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }