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
recommended

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

example.dartdart
// 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);
}
Name non-constant identifiers using `lowerCamelCase`.
2
3int My_Var = 0;
Name non-constant identifiers using `lowerCamelCase`.
4
5void Foo() {}
Name non-constant identifiers using `lowerCamelCase`.
6
7void f(int Bad_Param) {}
Name non-constant identifiers using `lowerCamelCase`.
9class A {
10 void Some_Method() {}
Name non-constant identifiers using `lowerCamelCase`.
11
12 A.My_Named();
Name non-constant identifiers using `lowerCamelCase`.
15void g() {
16 var Local_Var = 1;

Valid

example.dartdart
// 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.

falcon.jsonjson
{
  "linter": {
    "rules": {
      "style": {
        "non-constant-identifier-names": "error"
      }
    }
  }
}

Or silence one occurrence with a suppression comment; the reason is required.

example.dartdart
// falcon-ignore lint/style/non-constant-identifier-names: <reason>