Skip to main content

newline_before_return

Warns about missing newline before return in a code block

Example

BAD:

int fn() {
final a = 0;
return 1; // LINT
}

void fn2() {
if (true) {
final a = 0;
return; // LINT
}
}

GOOD:

int fn0() {
return 1; // OK for single-line code blocks
}

Function getCallback() {
return () {
return 1; // OK
};
}

int fn() {
final a = 0;

return 1; // newline added -- OK
}

void fn2() {
if (true) {
return; // right under a conditional -- OK
}
}