2 years ago

#12189

test-img

Technorocker

Flutter linter rules and structure in analysis_options.yaml file

I have been looking off and on for a few days now and I'm trying to customize the rules for linting my flutter project. I'd like to turn off the obvious warnings like unused local variables. Yet when I enter it into the rules section it doesn't work amongst other rules. Yet some do work.

I'm also confused as to the formatting. I see some answers on the internet that use a hyphen then the rule where others are stating the rule with a colon and a true or false. I tried the hyphen and I get a block mapping type of error thrown at me.

Here is my file right now...

include: package:flutter_lints/flutter.yaml
# include: package:lint/analysis_options.yaml

linter:
  rules:
    always_declare_return_types: false
    use_key_in_widget_constructors: false
    unused_element: false
    unused_local_variable: true
    unused_import: false
    avoid_print: false
    prefer_const_constructors: false
    require_trailing_commas: true
    always_use_package_imports: false

The trailing commas one worked but the more annoying and obvious warnings I cant seem to suppress.

Can someone please clarify the structure and maybe why the some rules are working and some arent?

If I do the quick fixes inside the files to ignore them it works but I want them project wide.

EDIT well the unused_local_variable is the warning that started me on this quest for information and understanding of how the analysis_options file works.

Unused_local_variables

flutter

dart

rules

suppress-warnings

linter

0 Answers

Your Answer

Accepted video resources