当前位置:网站首页>[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.102 . 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 )
边栏推荐
- MySQL learning record (9)
- Error in PIP installation WHL file: error: is not a supported wheel on this platform
- 《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!
- MySQL learning record (6)
- Etcd Raft 协议
- #include<>和#include“”的区别
- Blue Bridge Cup Eliminate last one (bit operation, code completion)
- Lightgbm principle and its application in astronomical data
- 【leetcode】1380. Lucky number in matrix
- Analysis of neural network
猜你喜欢

Gee: (II) resampling the image

Reading experience of just because

"New programmer 003" was officially launched, and the cloud native and digital practical experience of 30+ companies such as Huawei and Alibaba

20220702 how do programmers build knowledge systems?

An overview of the development of affective computing and understanding research

Structure array, pointer and function and application cases

Three chess games
![[use of pointer and pointer and array]](/img/dd/8017215c54aebcdf5c67e46e795d3b.jpg)
[use of pointer and pointer and array]

Read a doctor, the kind that studies cows! Dr. enrollment of livestock technology group of Leuven University, milk quality monitoring

基本IO接口技术——微机第七章笔记
随机推荐
*C语言期末课程设计*——通讯录管理系统(完整项目+源代码+详细注释)
【剑指 Offer 】56 - II. 数组中数字出现的次数 II
[Yu Yue education] reference materials of analog electronic technology of Nanjing Institute of information technology
PIP audit: a powerful security vulnerability scanning tool
[zero foundation I] Navicat download link
Structure array, pointer and function and application cases
Les trois principaux points de douleur traités par servicemesh
关于测试用例
D4:非成对图像去雾,基于密度与深度分解的自增强方法(CVPR 2022)
Daily book - low code you must understand in the era of digital transformation
pyqt图片解码 编码后加载图片
Attack and defense world PWN question: Echo
LightGBM原理及天文数据中的应用
Redis分布式锁故障,我忍不住想爆粗...
Browser - clean up the cache of JS in the page
【剑指 Offer】56 - I. 数组中数字出现的次数
C语言,实现三子棋小游戏
服务可见可观测性
Reading experience of just because
The failure rate is as high as 80%. What should we do about digital transformation?