prefer-boolean-prefixes
Suggests to prefix boolean variables, methods, fields and parameters with one of the configured prefixes.
⚙️ Config
Set ignored-names
(default is empty) to ignore specific function / method names.
Set ignore-methods
(default is false
) to exclude methods.
Set ignored-annotations
(default is empty) to ignore declarations with specific annotations.
Set ignore-fields
(default is false
) to exclude fields.
Set ignore-parameters
(default is false
) to exclude parameters.
Set prefixes
(default is [is
, are
, was
, were
, has
, have
, had
, can
, should
, will
, do
, does
, did
]) to configure the list of allowed prefixes.
dart_code_metrics:
...
rules:
...
- prefer-boolean-prefixes:
ignore-fields: true
ignore-parameters: true
ignored-names:
- some
- name
prefixes:
- is
- are
Example
❌ Bad:
class Some {
final bool test; // LINT
final bool isnotcorrect; // LINT
final bool _private; // LINT
bool someRandom() => false; // LINT
}
✅ Good:
class Some {
final bool hasTest;
final bool isCorrect;
final bool _isPrivate;
bool isCorrectMethod() => true;
}