Skip to main content

avoid-returning-void

added in: 1.15.0
🛠

Suggests calling functions or methods with a void return type separately from the return statement.

Returning void invocations can be confusing for code reviewers and introduce unnecessary changes if the return type changes.

Example

❌ Bad:

void someVoidFunction() {
...
}

void someFunction() {
return someVoidFunction(); // LINT
}

Future<void> asyncFn() async {
return someVoidFunction(); // LINT
}

✅ Good:

void someVoidFunction() {
...
}

void someFunction() {
someVoidFunction();

return;
}

Future<void> asyncFn() async {
someVoidFunction();

return;
}