Skip to main content

prefer-correct-for-loop-increment

added in: 1.8.0

Warns when a for loop increments a wrong variable.

Example

❌ Bad:

void main() {
var j = 1;

for (var i = 0; i < 10; j++) {} // LINT
}

✅ Good:

void main() {
var j = 1;

for (var i = 0; i < 10; i++) {}
for (var j = 0; j < 10; j++) {}
for (var i = 0; j < 10; j++) {}
}