我不知道出于什么原因,url_launcher(https://pub.dev/packages/url_launcher)在从Google Playstore下载应用程序后无法工作.在调试模式下,它的工作方式是正常的.但在Playstore上传应用程序并从那里下载之后,url Launcher没有启动任何url.为什么会这样呢?

import 'package:url_launcher/url_launcher.dart';

 onTap: () {
  launchURL("https://www.google.com");
},
..............
  launchURL(String url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

pubspec.yaml url_launcher: ^5.7.6

我还增加了android.permission.INTERNET

我使用的不是最新版本的url_launcher,所以使用最新版本可能会解决问题,但问题是最新版本的url_launcher需要最新版本的Flutter .升级Flutter 翼版本安全吗?我不能冒导致更多问题的风险,因为我的应用程序已经在生产中

这是我try 升级到最新版本url_launcher: ^5.7.10并运行flutter pub get时得到的结果

[xxxxx] flutter pub get
Running "flutter pub get" in xxxxx...                       
The current Flutter SDK version is 1.22.0-9.0.pre.

Because url_launcher >=5.7.7 <6.0.0-nullsafety depends on url_launcher_platform_interface >=1.0.9 <2.0.0-nullsafety which requires Flutter SDK version >=1.22.0 <2.0.0, url_launcher >=5.7.7 <6.0.0-nullsafety is forbidden.

So, because xxxxx depends on url_launcher ^5.7.10, version solving failed.
pub get failed (1; So, because storeifie depends on url_launcher ^5.7.10, version solving failed.)
exit code 1

推荐答案

首先,你们在Flutter 的开发频道(1.22.0-9.0.pre是一个开发版本,于2020年2月9日发布).由于您的应用程序正在生产中,请将频道更改为稳定,因为它没有中断的错误.

flutter channel stable

然后再进行Flutter 升级.

 flutter upgrade

现在,try 将url_launcher包升级到最新版本.应该行得通.

附言:不要担心Flutter 升级,只要你是在稳定分部升级.始终建议运行最新版本.

Dart相关问答推荐

Dart中的运算符(){…}做什么?

跳过 JavaScript 直接进入 Dart

在Flatter中,依赖项必须指定版本号?

如何限制TextSpan小部件的文本长度

Flutter 以编程方式触发 FutureBuilder

在 Dart 中,是否可以有一个 const 闭包映射?

dart:web_gl: 渲染警告:texture bound to texture unit 0 is not renderable

Flutter 错误:The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child

如何从目录中获取文件列表并将其传递给ListView?

Dart null 安全性不适用于类字段

如何缩小从 Dart 编辑器编译的 JavaScript 代码?

Error: The argument type "String?"can't be assigned to the parameter type"String" because "String?"s nullable and "String"isn't

Opa vs Dart vs Haxe vs CoffeeScript

CoffeeScript 和 Dart 对 JavaScript 的改进之间的主要区别是什么?

Dart:如何在异步函数中管理并发

如何在 Ubuntu 网络服务器上为 Dart 安装 pub(命令行使用)

如何在 Dart 中将 UTF-8 字符串转换为字节数组?

在 Dart 中,List.from 和 .of 以及 Map.from 和 .of 有什么区别?

Dart: 必须取消 Stream 订阅并关闭 StreamSinks 吗?

List firstWhere Bad state: No element