Skip to main content

newline-before-case

added in: 1.8.0
🛠
Pro+

Enforces a blank line between cases in a switch statement.

Example

❌ Bad:

final value = 'some-value';

switch (value) {
case '1': {
...
}
case '2': // LINT: Missing a blank line before 'case'. Try adding it.
...
case '3': // LINT: Missing a blank line before 'case'. Try adding it.
}

✅ Good:

final value = 'some-value';

switch (value) {
case '1': {
...
}

case '2':
case '3':
...
}