Tuan Anh Le
Tuan Anh Le

Reputation: 23

How to remove warning text beside my code in Flutter's Visual Studio Code

I am a new Flutter learner, and this is kinda annoy me, I think the "Problems" tab under is fully understand, I don't want to see warning next to my code. Is there a way I can disable or hide it? Thank you.

enter image description here

Upvotes: 0

Views: 2360

Answers (4)

pavel savelev
pavel savelev

Reputation: 1

go to analysis_options.yaml file that is in your root directory .

paste the following lines :


include: package:flutter_lints/flutter.yaml

linter:
  rules:
    prefer_const_constructors: false
    prefer_final_fields: false
    use_key_in_widget_constructors: false
    prefer_const_literals_to_create_immutables: false
    prefer_const_constructors_in_immutables: false
    avoid_print: false

Upvotes: 0

Mahesh Jamdade
Mahesh Jamdade

Reputation: 20221

Perhaps you are using some vscode plugin like https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens to show code diagnostics. Though that feature seems very useful to me incase you find that annoying you may disable it by going through your list of extensions.

Upvotes: 0

csemorf
csemorf

Reputation: 63

enter image description here

disable this line or add source.fixAll to config.json

Upvotes: 0

Pavan Kumar V
Pavan Kumar V

Reputation: 787

Hey, In visual studio code you can do minute changes.

Step1:

Press ctrl+shift+p , a command pallet will open enter image description here

Step2:

Type settings.json and click on Open Settings (JSON) a file will open enter image description here

step3:

Add this lines in that

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

**After this whenever you save, const will be added automatically.

Note: Sometimes you might get error because after saving some widgets are prefixed with const but, sometimes when your values in widget get dynamic, there will be a error, so be careful.

Upvotes: 1

Related Questions