How to disable a linting rule inline in flutter How to disable a linting rule inline in flutter dart dart

How to disable a linting rule inline in flutter


Use the // ignore: syntax, for example:

abstract class ReviewName {  // ignore: non_constant_identifier_names  static final NEW = 'NEW';  // ignore: non_constant_identifier_names  static final OLD = 'OLD';}

The list of rule names is here.


General answer

To ignore a single line, you can add a comment above the line:

// ignore: non_constant_identifier_namesfinal 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.yamllinter:  rules:    non_constant_identifier_names: false

See also