Reputation: 1120
In Visual Studio Code, how can you automatically add const
when you press (Ctrl + S)?
Upvotes: 13
Views: 16812
Reputation: 31
"editor.codeActionsOnSave": {
"source.fixAll": true
}
gives error = Incorrect type. Expected "string".
so, use this
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
Upvotes: 3
Reputation: 25070
Note: It is a simplified and updated version of Emirhan's answer with required changes
Upvotes: 8
Reputation: 51
If there are things like constants or changes that can be improved, I recommend you apply for the same Flutter recommendations. Run this in your terminal and that's it.
dart fix --apply
Upvotes: 5
Reputation: 1120
To add an auto const feature when you save the file in Flutter in Visual Studio Code, you should follow these steps:
Press (Ctrl + P) then search for (settings.json) file.
Add this code line to there;
"editor.codeActionsOnSave": {
"source.fixAll": true
}
Upvotes: 29