如何在 VS Code 中使用 args 运行 在 chrome 中颤动

How to run flutter in chrome with args in VS Code

我如何 运行 我的 flutter 应用 chrome 中带有参数?

我想 run/debug/attach 在与 --disable-web-security 的 chrome 会话中使用我的 flutter 应用程序。

最后我希望有一个单一的启动配置,它确实在单个 chrome 会话中启动我的应用程序(类似于 flutter run -d chrome)。

launch.json 中,我确实玩过 attach/launch、化合物、任务,但无法使其工作。

{
    "version": "0.2.0",
    "compounds": [
        {
            "name": "Launch D1",
            "configurations": [
                "Launch Chrome",
                "app1"
            ],
        }
    ],
    "configurations": [
        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "chrome",
            "webRoot": "${workspaceFolder}/app1",
            "runtimeArgs": [
                "--disable-web-security",
                "--user-data-dir=%APPDATA%\..\Local\tempc"
            ],
        },
        {
            "name": "app1",
            "cwd": "app1",
            "request": "launch",
            "type": "dart",
            "deviceId": "chrome"
        }
    ]
}

如果您在 Web 上遇到证书问题 运行,您可以使用 "runtimeArgs": ["--ignore-certificate-errors"]

禁用警告

您还可以遵循此 GitHub issue thread 中提到的其他解决方法。