zoukankan      html  css  js  c++  java
  • flutter打开第三方应用的实现?

    如果走完安装流程后运行Flutter时提示:

    export LANG=en_US.UTF-8 
    Error running pod install

    需要在配置文件.bash_profile中加上:

    export LANG=en_US.UTF-8

    1.flutter开发者网站下载url_launcher插件 下载链接

    2.在 pubspec.yaml 文件中添加依赖:

    dependencies:
        url_launcher: ^5.0.3

    3.安装:

    flutter pub get

    4.导入:

    import 'package:url_launcher/url_launcher.dart';

    5.使用:
    一:打开浏览器
    _launchURL、_openMapApp为自定义方法名 可以根据自己的场景自定义名称

    _launchURL() async {
         const url = 'https://flutter.io';
         if (await canLaunch(url)) {
              await launch(url);
         } else {
              throw 'Could not launch $url';
         }
    }

    资源搜索网站大全 https://www.renrenfan.com.cn 广州VI设计公司https://www.houdianzi.com

    二:打开外部APP

    打开外部APP 需要外部APP提供跳转的schema

     
     _openMapApp() async {
         const url = 'geo:52.32,4.917'; //APP提供的schema
         if (await canLaunch(url)) {
              await (launch(url)); //安卓中打开
         } else {
              //iOS中打开
              const url = 'http://maps.apple.com/?ll=52.32,4.917';
              if (await canLaunch(url)) {
                await launch(url);
              } else {
                throw 'Could not launch $url';
              }
         }
    }
  • 相关阅读:
    基础薄弱的反思
    最短路SPFA
    乌龟棋
    石子归并
    Linux学习2
    java 基础 数组
    java 基础 异常
    java 基础 接口
    java 基础 instance of
    solidity“abi.encode/abi.encodePacked”使用golang编码
  • 原文地址:https://www.cnblogs.com/xiaonian8/p/14132632.html
Copyright © 2011-2022 走看看