相关疑难解决方法(0)

I/UrlLauncher(17669):(url) 的组件名称为空

为什么它会抛出错误并提示我链接为空,即使链接存在?当我单独使用 launch (url) 时,链接打开没有任何问题。

在此输入图像描述

 String StateUrl = 'View App' ;
 var url = 'https://www.youtube.com/watch?v=-k0IXjCHObw' ;
body: Column(
        children: [
          Text(StateUrl),
          Center(
            child: ElevatedButton.icon(
                onPressed: () async{
                  try {
                    await canLaunch(url) ?
                    await launch(url):
                    throw 'Error';
                  } catch(e){
                    setState(() {
                      StateUrl = e.toString() ;
                    });
                  }
                },
                icon: const Icon(FontAwesomeIcons.link),
                label:  const Text('View Url')
            ),
          ),
        ],
      ),
Run Code Online (Sandbox Code Playgroud)

执行热重载:

D/EGL_emulation(17669): app_time_stats: avg=17852.65ms min=658.78ms max=35046.52ms count=2 I/UrlLauncher(17669): https://www.youtube.com/watch?v=-k0IXjCHObw的组件名称 为空 D/EGL_emulation(17669): app_time_stats: avg=8279.72ms min=8279.72ms max=8279.72ms count=1

dart flutter

26
推荐指数
4
解决办法
3万
查看次数

Flutter url_launcher 未在发布模式下启动 url

我不知道出于某种原因url_launcherhttps://pub.dev/packages/url_launcher)从 google Playstore 下载应用程序后无法正常工作。在调试模式下,它按应有的方式工作。但是在Playstore上上传应用程序并从那里下载后,url启动器没有启动任何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';
    }
  }
Run Code Online (Sandbox Code Playgroud)

pubspec.yaml url_launcher: ^5.7.6

我也添加了 android.permission.INTERNET

我没有使用最新版本,url_launcher所以可能使用最新版本可以解决问题,但问题是最新版本 url_launcher需要最新版本的颤振。升级flutter版本安全吗?由于我的应用程序已经投入生产,我不能冒险引发更多问题

这就是我尝试升级到 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 …
Run Code Online (Sandbox Code Playgroud)

url launcher dart flutter

4
推荐指数
4
解决办法
4523
查看次数

标签 统计

dart ×2

flutter ×2

launcher ×1

url ×1