Skip to main content

avoid-unnecessary-negations

added in: 1.4.0
🛠
preset: recommended

Warns when a negation can be simplified.

Example

❌ Bad:

void main() {
final someCondition = true;

if (!!someCondition) {} // LINT

if (!true) {} // LINT
}

✅ Good:

void main() {
final someCondition = true;

if (someCondition) {}

if (false) {}
}