Answer a question

When I choose Chrome to run my Flutter app, the resizing page doesn't work correctly and by searching through the internet I found this command to solve the problem:

flutter run -d chrome --web-renderer html

But I am wondering to know if there is a way to set it as a default command on VSCode to make it easier to run by just clicking on play button/run menu/ctrl+f5.

Answers

In VSCode you can add the launch.json file to the .vscode folder of your project. Then just fill the file with the following content. Afterwards you can select the debug options you just setup in the dropdown of your VSCode debugger and run them.

.vscode/launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug_option_1",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug",
            "args": [
                "-d",
                "chrome",
                "--web-renderer",
                "html",
            ]
        },
        {
            "name": "debug_option_2 (release mode)",
            "request": "launch",
            "type": "dart",
            "flutterMode": "release",
            "args": [
                "-d",
                "chrome",
                "--web-renderer",
                "html",
            ]
        },
    ]
}

enter image description here

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品