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>
- Android端:在
- 替换为新版本
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
相关产品推荐
相关产品推荐

