You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter点击Sign Up调用launch(url)打开浏览器无响应如何解决

Flutter点击Sign Up无跳转问题解决步骤
  • 确认已在pubspec.yaml中正确添加url_launcher依赖,执行flutter pub get完成安装后再运行项目。
  • 完成对应平台的权限配置:
    • Android端:在android/app/src/main/AndroidManifest.xml的<manifest>标签内添加以下内容:
      <!-- 网络访问权限 -->
      <uses-permission android:name="android.permission.INTERNET" />
      <!-- 目标SDK≥30时需要添加以下查询声明 -->
      <queries>
        <intent>
          <action android:name="android.intent.action.VIEW" />
          <data android:scheme="https" />
        </intent>
      </queries>
      
    • iOS端:在ios/Runner/Info.plist的<dict>标签内添加以下配置:
      <key>LSApplicationQueriesSchemes</key>
      <array>
        <string>https</string>
      </array>
      
  • 替换为新版本url_launcher的标准调用写法,旧版launch方法已被弃用可能无法生效:
    return Container(
      child: GestureDetector(
        onTap: () async {
          final Uri targetUrl = Uri.parse("https://my.drclubs.ir/");
          await launchUrl(targetUrl);
        },
        child: RichText(
          text: TextSpan(
            children: [
              TextSpan(
                text: "Don`t have an Account?",
                style: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                    fontWeight: FontWeight.w500),
              ),
              TextSpan(
                text: "Sign Up",
                style: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                    fontWeight: FontWeight.bold),
              ),
            ],
          ),
        ),
      ),
    );
    
  • 若修改后仍无响应,可临时给Container添加背景色测试点击区域是否被其他组件遮挡,确认点击时onTap回调能正常触发。
  • 检查跳转链接是否完整,必须携带https://协议头,不可省略。

内容的提问来源于stack exchange,提问作者Navid Shokoufeh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 08:45:03