3

Is it possible? related to flutter plugin? or is it related to the Problem pane? I can remove hints from problem pane but not from the editor (shows squiggles). Since flutter is already quite verbose, these don't help, especially in the middle of writing the software.(import, consts etc)

5 Answers 5

6

From Dart 2.15, you can add the lint rules that you would like to ignore to your analysis_options.yaml file. If you do not have it in your project. Add it to your root project system. After that you can add the lint rules that you would like to ignore to it.

include: package:flutter_lints/flutter.yaml

linter:
  rules:
    prefer_const_constructors_in_immutables:
      enabled: false

p.s. My honest and professional opinion is for you to follow the analyzer. It works for your own good.

3

All the issues that are displayed can be controlled by adding/removing rules in your source code. It's also a good idea to actually address those issues than just silencing them.

For instance, you would normally get a warning if you have unused imports like so:

enter image description here

However, you can either use a directive to disable them in the current file as shown in top of this code:

enter image description here

1
  • Yes, I know what I am doing. I only want to silence them temporarily.
    – kobi7
    Commented Feb 24, 2022 at 12:35
1

Here is a shortcut method to deal with.

  1. Goto that line where squiggly line is
  2. Click on that small icon.
  3. Choose what you want

enter image description here

You can add const as well

1

In another way, you can use fix_import solution. While you're writing code, use the fix import command with cmd + p or control + p then it'll be automatically fixed to the relative path to all your import. enter image description here

https://marketplace.visualstudio.com/items?itemName=luanpotter.dart-import

1

Also, you could fix them automatically when you save the file.

You can add these lines to your settings.json:

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.organizeImports": true,
    "source.fixAll": true
  }
}

With this, when you save your file, it should:

  • Format it
  • Order your imports
  • Remove the duplicated imports and fix the other lints of the file (if fixables)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.