在 VS Code 中,如何在按下 (Ctrl + S) 时自动添加 const ?
**要在 VS Code 中的 Flutter 中保存文件时添加自动 const 功能,您应该按照以下步骤操作:**
1-) 按 (ctrl + P) 然后搜索 (settings.json) 文件。
2-) 将此代码行添加到那里;
"editor.codeActionsOnSave": {
"source.fixAll": true
}
如果有诸如常量或更改之类可以改进的事情,我建议您申请相同的 flutter 建议,在终端中运行它,仅此而已。
https://docs.flutter.dev/tools/flutter-fix
dart fix --apply