How to run flutter in chrome with args in VS Code

Viewed 2009

How can I run my flutter app in chrome with args?

I want to run/debug/attach my flutter app in a chrome session with --disable-web-security.

In the end I would expect to have a single launch configuration that does launch my app in a single chrome session (similar to flutter run -d chrome).

In the launch.json, I did play around with attach/launch, compounds, tasks but could not make it work.

{
    "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"
        }
    ]
}
1 Answers

If you're having certificate issues running on web, you can disable the warnings using "runtimeArgs": ["--ignore-certificate-errors"]

You can also follow other workarounds mentioned on this GitHub issue thread.

Related