前言
现在市面上的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';
}
}
希望这篇博客可以帮助更多小伙伴