Skip to content

avoid_unnecessary_enum_prefix

v1.0.0 Warning Class Naming

This rule flags an enum constant that repeats the name of its own enum.

This rule is in the opinionated preset.

enum Status { statusActive } reads as Status.statusActive at every call site, where the type already says Status. The prefix is a habit carried over from languages whose enum constants share one namespace; Dart scopes them to the enum, so it buys nothing and lengthens every use.

Dropping it also makes dot shorthands read properly: .active rather than .statusActive.

Two shapes are deliberately not reported: a constant named exactly like its enum (Status.status is the whole word, not a prefix), and one that merely starts with the same letters (statusable), since the prefix has to end at a word boundary.

See also: Enumerated types

enum Status {
statusActive,
statusArchived,
}
// Every use repeats the type name.
final state = Status.statusActive;
enum Status {
active,
archived,
}
final state = Status.active;

To disable this rule:

many_lints.yaml
rules:
avoid_unnecessary_enum_prefix: false

To keep the rule on but skip certain paths, use per-rule exclude.