Search code examples
fluttervisual-studio-codeunused-variables

VScode doesn't suggest unused declarations


I'm making a flutter app with VScode and I have a lot of unused variables declared at the top of the code, but it doesn't show me the underline. Is there a way to setting this?

P.D:The rest of unused code works.

Thank you!


Solution

  • Dart linter and analyzer have no rule for unused global variables, only for local variables. Here is all available rules and diagnostic messages:

    https://dart.dev/tools/diagnostic-messages#diagnostics

    https://dart-lang.github.io/linter/lints/

    So answer is: you can't do that.

    There is an open issue on github about opportunity to add custom rules, you can track it - https://github.com/dart-lang/linter/issues/697