avoid-block-in-switch-case
Suggests to avoid wrapping all switch case statements in a code block.
Example
❌ Bad:
void fn(int val) {
switch (val) {
// LINT: Avoid wrapping all switch case statements in a code block.
// Try moving all statements out and removing this code block.
case 1:
{
print('hi');
{
final value = 4;
}
}
// LINT: Avoid wrapping all switch case statements in a code block.
// Try moving all statements out and removing this code block.
case 2:
{
print('hi');
}
}
}
✅ Good:
void fn(int val) {
switch (val) {
case 1:
print('hi');
{
final value = 4;
}
case 2:
print('hi');
}
}