Is there a way to disable a linting rule for a line in flutter?
I have a specific use case where I want to disable linting for two lines. I have a lot of business logic already written so I cannot change the code.
abstract class ReviewName { static final NEW = 'NEW'; static final OLD = 'OLD'; }
The above code will have linting errors: Name non-constant identifiers using lowerCamelCase.dart(non_constant_identifier_names)
Is there any way I avoid the lint error for only the two lines?
Enabling default Lint Rules. You can use the Dart linter (Which is a recommendation from the Dart Team), or the Flutter_lints package which extends the dart linter for Flutter, it contains recommended sets of lints for your Flutter Applications and packages.
The linter gives you feedback to help you catch potential errors and keep your code in line with the published Dart Style Guide. Enforceable lint rules (or "lints") are cataloged here and can be configured via an analysis options file.
To ignore a single line, you can add a comment above the line:
// ignore: non_constant_identifier_names final NEW = 'NEW';
To ignore for the whole file, you can add a comment at the top of the file:
// ignore_for_file: non_constant_identifier_names
To ignore for the whole project, you can set the rule to false in your analysis_options.yaml file:
include: package:lints/recommended.yaml linter: rules: non_constant_identifier_names: false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With