当前位置:网站首页>[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
[shutter] shutter opens a third-party application (url|launcher plug-in search and installation | url| launcher plug-in official example | open browser | open a third-party application)
2022-07-02 22:09:00 【Programmer community】
List of articles
- One 、url_launcher Plug in search and installation
- 1、 Search for url_launcher plug-in unit
- 2、 install url_launcher plug-in unit
- Two 、url_launcher Official plug-in example
- 3、 ... and 、 Open the browser
- Four 、 Open a third party app
- 5、 ... and 、 Complete code example
- 6、 ... and 、 Related resources
One 、url_launcher Plug in search and installation
1、 Search for url_launcher plug-in unit
With the help of url_launcher Third party plug-ins , You can open third-party applications ;
The plug-in is Flutter Official plug-in for opening third-party applications ;
stay https://pub.dev/packages Search and install url_launcher plug-in unit ;
The address of the plug-in is https://pub.dev/packages/url_launcher
2、 install url_launcher plug-in unit
Installing a plug-in : stay https://pub.dev/packages/url_launcher/install The page has the installation method of the plug-in ;
1 . Configuration dependency : stay pubspec.yaml Configure dependencies in the configuration file ;
dependencies: url_launcher: ^5.7.10
2 . Get plug-ins : Click on the " Pub get " Button to get the plug-in , In the following Message The panel shows Running "flutter pub get" in flutter_cmd... 0.5s
, This indicates that the plug-in has been downloaded successfully ;
3 . Import header file :
import 'package:url_launcher/url_launcher.dart';
Two 、url_launcher Official plug-in example
The official sample : This is a https://pub.dev/packages/url_launcher The official code provided by ;
import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';void main() {
runApp(Scaffold( body: Center( child: RaisedButton( onPressed: _launchURL, child: Text('Show Flutter homepage'), ), ), ));}_launchURL() async {
const url = 'https://flutter.dev'; if (await canLaunch(url)) {
await launch(url); } else {
throw 'Could not launch $url'; }}
3、 ... and 、 Open the browser
Set up RaisedButton Button components , Click this button , Open browser automatically , And open the home page of this blog ;
// Open browser button RaisedButton( // Anonymous functions onPressed: () async {
const url = 'https://blog.csdn.net/shulianghan'; if (await canLaunch(url)) {
await launch(url); } else {
throw 'Could not launch $url'; } }, // The components displayed by the button child: Text(" Open the browser "),),
Four 、 Open a third party app
The premise of opening third-party applications is , Know the of the application schema or url , These are all made by third parties app The developers of ;
Google maps scheme yes “geo: precision , dimension ” ;
Apple map url yes “http://maps.apple.com/?ll= precision , dimension ”
// open Google Map RaisedButton( // Anonymous functions onPressed: () async {
// Android Google maps scheme , Behind is the latitude and longitude of Haidian District, Beijing const url = 'geo:116.3,39.95'; if (await canLaunch(url)) {
// Android mobile phone , open Google Map await launch(url); } else {
// If the Android phone doesn't open, it means it's an Apple phone const url_ios = 'http://maps.apple.com/?ll=116.3,39.95'; if (await canLaunch(url_ios)) {
await launch(url_ios); } else {
throw 'Could not launch $url'; } } }, // The components displayed by the button child: Text(" Open the map "),),
5、 ... and 、 Complete code example
Complete code example :
import 'package:flutter/material.dart';import 'package:url_launcher/url_launcher.dart';class LauncherPage extends StatefulWidget {
@override _LauncherPageState createState() => _LauncherPageState();}class _LauncherPageState extends State<LauncherPage> {
@override Widget build(BuildContext context) {
return MaterialApp( title: " Third party application jump ", theme: ThemeData(primarySwatch: Colors.blue), home: Scaffold( appBar: AppBar( title: Text(" Third party application jump "), leading: GestureDetector( onTap: (){
Navigator.pop(context); }, child: Icon(Icons.arrow_back_ios), ), ), body: Container( // centered alignment: Alignment.center, // Vertical linear layout child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ // Open browser button RaisedButton( // Anonymous functions onPressed: () async {
const url = 'https://blog.csdn.net/shulianghan'; if (await canLaunch(url)) {
await launch(url); } else {
throw 'Could not launch $url'; } }, // The components displayed by the button child: Text(" Open the browser "), ), // open Google Map RaisedButton( // Anonymous functions onPressed: () async {
// Android Google maps scheme , Behind is the latitude and longitude of Haidian District, Beijing const url = 'geo:116.3,39.95'; if (await canLaunch(url)) {
// Android mobile phone , open Google Map await launch(url); } else {
// If the Android phone doesn't open, it means it's an Apple phone const url_ios = 'http://maps.apple.com/?ll=116.3,39.95'; if (await canLaunch(url_ios)) {
await launch(url_ios); } else {
throw 'Could not launch $url'; } } }, // The components displayed by the button child: Text(" Open the map "), ), ], ), ), ), ); }}
Running effect :
6、 ... and 、 Related resources
Reference material :
- Flutter Official website : https://flutter.dev/
- Flutter Plug in download address : https://pub.dev/packages
- Flutter Developing documents : https://flutter.cn/docs ( Strongly recommend )
- official GitHub Address : https://github.com/flutter
- Flutter The Chinese community : https://flutter.cn/
- Flutter Practical tutorial : https://flutter.cn/docs/cookbook
- Flutter CodeLab : https://codelabs.flutter-io.cn/
- Dart Chinese document : https://dart.cn/
- Dart Developer website : https://api.dart.dev/
- Flutter Chinese net ( unofficial , The translation is very good ) : https://flutterchina.club/ , http://flutter.axuer.com/docs/
- Flutter Related issues : https://flutterchina.club/faq/ ( It is recommended to watch it at the introductory stage )
Blog source download :
GitHub Address : https://github.com/han1202012/flutter_cmd ( Keep updating with the progress of the blog , There may not be the source code of this blog )
Blog source snapshot : https://download.csdn.net/download/han1202012/15541330 ( The source code snapshot of this blog , You can find the source code of this blog )
边栏推荐
- LandingSite eBand B1冒烟测试用例
- Une semaine de vie
- 【剑指 Offer】57. 和为s的两个数字
- How is LinkedList added?
- : last child does not take effect
- Interpretation of CVPR paper | generation of high fidelity fashion models with weak supervision
- [leetcode] sword finger offer 11 Rotate the minimum number of the array
- Leetcode theme [array] -169- most elements
- Etcd Raft 协议
- 2019 Nanchang (relive the classic)
猜你喜欢
PIP audit: a powerful security vulnerability scanning tool
如何防止你的 jar 被反编译?
Gbase8s database type
LandingSite eBand B1冒烟测试用例
From "bronze" to "King", there are three secrets of enterprise digitalization
How to prevent your jar from being decompiled?
Reading experience of just because
The difference between include < > and include ""
The failure rate is as high as 80%. What should we do about digital transformation?
MySQL learning record (4)
随机推荐
VictoriaMetrics 简介
Web侧防御指南
C language, to achieve three chess games
Riding the wind of "cloud native" and stepping on the wave of "digitalization", new programmer 003 starts pre-sale
An overview of the development of affective computing and understanding research
pyqt图片解码 编码后加载图片
Blue Bridge Cup Winter vacation homework (DFS backtracking + pruning)
*C language final course design * -- address book management system (complete project + source code + detailed notes)
Unity3D学习笔记4——创建Mesh高级接口
MySQL learning record (9)
PIP version update timeout - download using domestic image
pip安装whl文件报错:ERROR: ... is not a supported wheel on this platform
腾讯三面:进程写文件过程中,进程崩溃了,文件数据会丢吗?
Gee: (II) resampling the image
[shutter] shutter gesture interaction (click event handling | click OnTap | double click | long press | click Cancel | press ontapdown | lift ontapup)
如何访问kubernetes API?
Centos7 installation and configuration of redis database
地理探测器原理介绍
tinymce可视化编辑器增加百度地图插件
Blue Bridge Cup Eliminate last one (bit operation, code completion)