Flutter VSCode 设置启动参数

6/10/2022 flutter

有些时候我们需要运行 flutter 的时候指定参数,比如,我想在 flutter for web 的项目中运行的时候指定项目:

flutter run -d Chrome --web-port=53794

这里是指定运行的端口号。

对于这 -d Chrome --web-port=53794 这串参数,在 vscode 中如何配置?

.vscode/launch.json 文件中:

"version": "0.2.0",
    "configurations": [
        {
            "name": "web-demo",
            "request": "launch",
            "type": "dart",
            "args": [
                "-d", "Chrome",
                "--web-port=53794"
            ]
        },
        {
            "name": "web-demo (profile mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "profile"
        },
        {
            "name": "web-demo (release mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "release"
        }
    ]

这个配置项,就可以设置参数

"args": [
    "-d", "Chrome",
    "--web-port=53794"
]
上次更新: 10/20/2022, 5:36:35 AM