no_literal_bool_comparisons
Don’t compare booleans to boolean literals.
This rule is available as of Dart 3.1.0-wip.
This rule has a quick fix available.
Details
From Effective Dart:
DON’T use true
or false
in equality operations.
This lint applies only if the expression is of a non-nullable bool
type.
BAD:
if (someBool == true) {
}
while (someBool == false) {
}
GOOD:
if (someBool) {
}
while (!someBool) {
}
Usage
To enable the no_literal_bool_comparisons
rule,
add no_literal_bool_comparisons
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- no_literal_bool_comparisons