Skip to main content

avoid-unnecessary-negations

added in: 1.4.0
🛠
Pro+
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) {}
}