I have a few variables that I am not using/referring to anywhere in the project so I am getting a unused_local_variable
warning.
Currently I am using
// ignore_for_file: unused_local_variable
to ignore those warning for that file but I have many files and I don't want to write the same in each one of them. So, how can I suppress this warning for the entire project?
Adding this to analysis_options.yaml
file didn't work:
linter:
rules:
unused_local_variable: false
CodePudding user response:
unused_local_variables
isn't a lint rule (it's not listed by https://dart.dev/tools/linter-rules or in https://github.com/dart-lang/linter/blob/main/example/all.yaml), so disabling it under linter: rules:
will have no effect.
unused_local_variables
instead is an analyzer code. Per https://dart.dev/guides/language/analysis-options#ignoring-rules, you can edit your analysis_options.yaml
file and add:
analyzer:
errors:
unused_local_variable: ignore
That said, really you should just get rid of your unused local variables.