简体   繁体   English

按下 ElevatedButton 时,我想打开路由应用程序。 Flutter

[英]when on press on ElevatedButton I want open Routing applications. Flutter

I get current location and my destination in app, when on press on ElevatedButton I want open Routing applications like google maps or Waze in user mobile.我在应用程序中获取当前位置和目的地,当按下 ElevatedButton 时,我想在用户移动设备中打开路由应用程序,如谷歌地图或 Waze。

  ElevatedButton(
                    onPressed: () {

                },
                ),

how can I do that?我怎样才能做到这一点?

use this package and do it like this:使用这个package并这样做:

Future<void> openMap(double latitude, double longitude) async {
    String googleUrl = 'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
    if (await canLaunch(googleUrl)) {
      await launch(googleUrl);
    } else {
      throw 'Could not open the map.';
    }
  }

Its better to use this package like this:最好像这样使用这个package

Future<void> openMap(double latitude, double longitude) async {
  String googleUrl = 'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
  var _params;
  Uri googleUri = Uri.parse(googleUrl).replace(queryParameters: _params);
  if (await canLaunchUrl(googleUri)) {
    await launchUrl(googleUri);
  } else {
    throw 'Could not open the map.';
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想访问所有应用程序的使用时间。 我如何在颤振中编程? - I want to access the usage time of all applications. How do i program this in flutter? 当我在颤动中按下 ElevatedButton 时,我希望能够更改 Fontfamily - I would like to be able to change the Fontfamily when I press the ElevatedButton in flutter 如何使用 BottomNavigationBar 以及 Flutter 中的 ElevatedButton 进行导航 - how to navigate using BottomNavigationBar and also with ElevatedButton press in Flutter 如何在 Flutter 中将“RaisedButton”升级为“ElevatedButton”? - How can I upgrade a "RaisedButton" to "ElevatedButton" in Flutter? "当 ElevatedButton 的 onPressed 运行时未触发 Flutter FutureBuilder" - Flutter FutureBuilder not triggered when onPressed of ElevatedButton runs 我无法更改 ElevatedButton 颜色,Flutter - I can't change ElevatedButton color, Flutter 需要您的支持:当我按下收藏按钮时,我想在我的 Flutter 数据库中获取产品 ID - Need your HELD : I want to get the product ID in my Flutter database when I press the favorite button 当我在颤抖中按下RaisedButton时,我想从TextFormField中获取值 - I want to get the value from a TextFormField when i press a RaisedButton in flutter 我有一个变量,我想在按下按钮 flutter dart 时显示一个对话框 - I have a variable and I want to display a dialog box when press the button flutter dart Flutter 2 MaterialApp buttonTheme for ElevatedButton - flutter 2 MaterialApp buttonTheme for ElevatedButton
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM