// ignore_for_file: non_constant_identifier_names
class Class1 {
final _count_me = 0;
final _count2_1 = 0;
Class1() {
_count_me + _count2_1;
}
}
// ignore_for_file: -non_constant_identifier_names
class Class2 {
final count_me = 0; // lint error with non_constant_identifier_names
final _count2 = 0;
Class2() {
count_me + _count2;
}
}
I've tried // ignore_for_file: -non_constant_identifier_names
but it's not working.
I want disable non_constant_identifier_names
on Class1
, but enable it on Class2
.
-
is not working in Android Studio, Class2.count_me
still no lint warning.
// ignore_for_file:
will make the specified linter rule being ignored in the whole file, even if this comment is not on the top of the file (so it will make the code before and after this line ignore the rule).
You should use // ignore:
instead. This will ignore a linter rule only for the line below it.
// ignore: non_constant_identifier_names
class Class1 {
final _count_me = 0;
final _count2_1 = 0;
Class1() {
_count_me + _count2_1;
}
}
class Class2 {
final count_me = 0; // lint error with non_constant_identifier_names
final _count2 = 0;
Class2() {
count_me + _count2;
}
}
See also: