# Debugging

Debugging a Flutter application can be really helpful when you want to understand and fix errors.

In this topic we will explain how you can debug Flutter applications in VS Code.

# VS Code debugging

  • Open VS Code and search for the debug icon in the left menu
    vs code debugging

  • Click on it and choose for create a launch.json file
    vs code launch json

    WARNING

    If there is already a launch.json file (or if there are already some configurations defined) you can add a new configuration to the configurations array

  • Add the following content to the launch.json file:




 
 
 
 
 
 
 
 
 
 
 



{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "web debugging",
            "deviceId": "chrome",
            "program": "lib/main.dart",
            "request": "launch",
            "type": "dart",
            "args": [
                "--web-port=5000",
                "--web-enable-expression-evaluation"
            ],
        },
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  • Launch the debugger and choose the web debugging configuration
    vs code launch debugging
  • Add some breakpoints and start debugging

WARNING

  • It's possible that VS Code asks you to enable Flutter web debugging...
  • Just click 'Yes' and go for it!
Last Updated: 9/12/2022, 1:49:39 PM