Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I auto add 'const' in Flutter in Visual Studio Code?

In Visual Studio Code, how can you automatically add const when you press (Ctrl + S)?

like image 285
Emirhan Selim Uzun Avatar asked Feb 01 '26 09:02

Emirhan Selim Uzun


2 Answers

To add an auto const feature when you save the file in Flutter in Visual Studio Code, you should follow these steps:

  1. Press (Ctrl + P) then search for (settings.json) file.

  2. Add this code line to there;

     "editor.codeActionsOnSave": {
         "source.fixAll": true
     }
    
like image 110
Emirhan Selim Uzun Avatar answered Feb 03 '26 04:02

Emirhan Selim Uzun


  • Press Ctrl + Shift + P
  • Search settings.json
    • Open the User Settings(Json)

      Enter image description here

    • Add the following code

       "editor.codeActionsOnSave": {
        "source.fixAll": true
      }
      
      

Note: It is a simplified and updated version of Emirhan's answer with required changes

like image 25
krishnaacharyaa Avatar answered Feb 03 '26 06:02

krishnaacharyaa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!