我用過url_launcher包。
String query = Uri.encodeComponent(Utils.getSelectedStoreAddress());
var appleUrl = 'maps:q=$query';
var googleUrl = 'https://www.google.com/maps/search/?api=1&query=$query';
_launch(appleUrl);
_launch(googleUrl);
Future<void> _launch(String url) async {
await canLaunch(url)
? await launch(url)
: _showSnackBar('could_not_launch_this_app'.tr());
}
一切正常,直到我收到此警告:
info: 'canLaunch' is deprecated and shouldn't be used. Use canLaunchUrl instead.
uj5u.com熱心網友回復:
我將代碼更改如下,一切正常:
String query = Uri.encodeComponent(Utils.getSelectedStoreAddress());
Uri appleUrl = Uri.parse('maps:q=$query');
Uri googleUrl = Uri.parse('https://www.google.com/maps/search/?api=1&query=$query');
_launch(appleUrl);
_launch(googleUrl);
Future<void> _launch(Uri url) async {
await canLaunchUrl(url)
? await launchUrl(url)
: _showSnackBar('could_not_launch_this_app'.tr());
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/469353.html
上一篇:使用來自另一個頁面的url呼叫javascript函式(帶引數)的最佳(和安全)方法
下一篇:Python:從URL請求大負載