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

运行Flutter Web项目时,如何在已打开的Chrome中打开localhost?

解决Flutter在现有Chrome实例中启动并保持调试关联的方法

操作步骤

  1. 启动带远程调试的Chrome实例
    先关闭所有Chrome窗口,根据你的系统执行对应命令,启动已登录配置的Chrome并开启远程调试:
  • Windows:start chrome --remote-debugging-port=9222
  • macOS:open -a "Google Chrome" --args --remote-debugging-port=9222
  • Linux:google-chrome --remote-debugging-port=9222
  1. 修改Flutter运行命令
    在原有命令基础上添加--web-browser-flag="--remote-debugging-port=9222"参数,最终命令为:
flutter run --debug -d chrome --target=lib/main_development.dart --web-port=64146 --web-browser-flag="--remote-debugging-port=9222"

执行后,Flutter会在你已登录的Chrome实例中打开新标签页运行应用,同时保持调试关联,可正常查看日志和进行调试操作。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 18:47:02