Skip to main content

avoid-getter-prefix

added in: 1.22.0
⚙️
Pro+

Warns when a getter name starts from a banned prefix.

note

This rule requires configuration in order to highlight any issues.

⚙️ Config

Set prefix (default is empty) to configure a regular expression for the not allowed prefix.

dart_code_metrics:
...
rules:
...
- avoid-getter-prefix:
prefix: '^get'

Example

❌ Bad:

abstract class ModalRoute {
bool get getBarrierDismissible; // LINT
}

class Some implements ModalRoute {

bool get getBarrierDismissible => false;
}

✅ Good:

abstract class ModalRoute {
bool get isBarrierDismissible;
}

class Some implements ModalRoute {

bool get isBarrierDismissible => false;
}