VSCode에서 Flutter 코드 작성 중 파란 줄이 엄청 많이 뜨는 경우가 있는데, 문구는 아래와 같다
Use 'const' with the constructor to improve performance.
Try adding the 'const' keyword to the constructor invocation.dart prefer_const_constructors
prefer_const_constructors
Learn more about the prefer_const_constructors linter rule.
dart.dev
변하지 않을 상수에는 const를 쓰는 걸 권장한다.. 라는 것인데, 어느 것이 const인지 판별하다 오히려 오류가 날 수도 있다는 단점이 있다.
파란 줄을 뜨게 하지 않으려면
VSCode의 Settings.json으로 이동하여
editor.codeActionsOnSave 부분을 아래와 같이 수정해 준다.
("editor.formatOnSave": true인지도 확인하자)
"editor.codeActionsOnSave": {
"source.fixAll": true
//"source.fixAll.eslint": "explicit"
},
짠 알아서 const를 넣어 주고 파란줄도 사라졌습니다
출처: https://nomadcoders.co/flutter-for-beginners