Flutter开发-------App调用高德地图

App调用高德地图

前言

现在市面上的app中,有许多的app已经实现了:点击按钮跳转到高德,百度等第三方app进行操作。今天我们就来实现这个效果

技术栈

url_launcher: ^5.1.1

实例代码分析

实现的代码不难,不要是自己去查找资源,本博客以高德为例子,高德官方查找等多的资料

	import 'package:flutter/material.dart';
	import 'package:url_launcher/url_launcher.dart';
	
	void main() {
	  runApp(
	    MaterialApp(
	      home:  Scaffold(
	        body: Center(
	          child: RaisedButton(
	            onPressed: _launchURL,
	            child: Text('Show Flutter homepage'),
	          ),
	        ),
	      ),
	    )
	  );
	}
	
	_launchURL() async {
	  const url = 'androidamap://keywordNavi?sourceApplication=softname&keyword=宛委山景区&style=2';
	  if (await canLaunch(url)) {
	    await launch(url);
	  } else {
	    throw 'Could not launch $url';
	  }
	}

希望这篇博客可以帮助更多小伙伴

发布了50 篇原创文章 · 获赞 35 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_35905501/article/details/97773107