Constant name is not lowerCamelCase

ID

dart.maintainability.constant_identifier_names

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Naming

Language

Dart

Description

Reports a const declaration whose name is not lowerCamelCase - SCREAMING_CAPS (MAX_RETRIES), snake_case (retry_backoff) or UpperCamelCase (PageSize). A leading underscore for library privacy is allowed, so _privateLimit is not reported.

Rationale

Dart deliberately does not give constants a naming form of their own: lowerCamelCase for every member and variable, UpperCamelCase for types. The value of that convention is that the spelling of a name tells the reader what kind of thing it is, so SCREAMING_CAPS reads as a name imported from C or Java, and PageSize reads as a type at its use site. It also makes constness look like part of the API when it is not: whether a value is const, final or a getter is an implementation detail the caller should be free to change without renaming anything, and a name that shouts its constness has to be revisited every time that changes.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Constant name is not lowerCamelCase
const MAX_RETRIES = 3;

Remediation

Rename the constant to lowerCamelCase - maxRetries, retryBackoff, pageSize - keeping any leading underscore for a private one. Where a value is part of a group of related constants, consider an enum or a class of static constants instead, which gives the group a name of its own.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved