non-constant-identifier-names
Same as non_constant_identifier_names in Dart lints
- Group
- Style
- Path
lint/style/non-constant-identifier-names- Default
- On (recommended)
- Origin
- Dart lints
- Rule
- 299 of 512
Flags non-constant identifiers that are not written in lowerCamelCase.
Dart convention reserves lowerCamelCase for everything that holds a runtime
value — non-const variables and fields, formal and closure parameters, for-in
and pattern variables, catch clause bindings, named constructors, and
function, method, getter, and setter names. Consistent casing lets readers
distinguish these from types (UpperCamelCase) and compile-time constants at a
glance. Operator names are exempt: they are not identifiers. The check mirrors
the analyzer's isLowerCamelCase, including optional trailing underscores
and underscore-digit word boundaries. Field formals are exempt because the
corresponding field declaration is checked separately.
Constants (see constant-identifier-names) are covered by a separate rule.
Invalid
// Non-constant identifiers must be lowerCamelCase.
int My_Var = 0;
void Foo() {}
void f(int Bad_Param) {}
class A {
void Some_Method() {}
A.My_Named();
}
void g() {
var Local_Var = 1;
print(Local_Var);
} int My_Var = 0; void Foo() {} void f(int Bad_Param) {}class A { void Some_Method() {} A.My_Named();void g() { var Local_Var = 1;Valid
// lowerCamelCase non-constant identifiers.
int myVar = 0;
void foo() {}
void f(int goodParam) {}
class A {
void someMethod() {}
A.myNamed();
}
void g() {
var localVar = 1;
var _private = 2;
print(localVar + _private);
}
void h(int _) {}Configure non-constant-identifier-names
Set its severity in falcon.json. See the configuration guide.
{
"linter": {
"rules": {
"style": {
"non-constant-identifier-names": "error"
}
}
}
}Or silence one occurrence with a suppression comment; the reason is required.
// falcon-ignore lint/style/non-constant-identifier-names: <reason>More style rules
- omit-local-variable-types
omit_local_variable_typesFlags local variable type annotations that repeat the initializer's type.
- only-throw-errors
only_throw_errorsrecommendedOnly throw instances of classes that extend
ExceptionorError. - package-names
package_namesrecommendedcross-fileRequire package names to be valid
lower_case_with_underscoresidentifiers. - parameter-assignments
parameter_assignmentsDon't reassign parameters of functions, methods, or constructors.
- parameters-ordering
Requires named parameters to follow the explicitly configured alphabetical order.
- pattern-fields-ordering
Flags named object and record pattern fields that violate the configured order.
- prefer-adjacent-string-concatenation
prefer_adjacent_string_concatenationrecommendedFlags two string literals joined with the
+operator. - prefer-align-over-containerflutter
Prefers
Alignover aContainerused only foralignment.