Skip to main content

binary-expression-operand-order

added in: 1.6.0
🛠
Free+

Warns when a literal value is on the left-hand side in binary expressions.

❌ Bad:

final a = 1 + b; // LINT: Prefer literals at right-hand side in binary expressions. Try swapping the operands.

✅ Good:

final a = b + 1;