avoid-redundant-else
preset: recommended
Checks for else
blocks that can be removed without changing semantics.
Example
❌ Bad:
class SomeClass {
String someString = '123';
void withInstance() {
if (someString == '0') {
print("Nothing to do");
return;
} else { // LINT
print("Moving on...");
}
}
}
✅ Good:
class SomeClass {
String someString = '123';
void withInstance() {
if (someString == '0') {
print("Nothing to do");
return;
}
print("Moving on...");
}
}