Dart Analyze logoDart Analyze/
DRT-W1201

Prefer intValue.isOdd/isEven instead of checking the result of % 2DRT-W1201

Major severityMajor
Anti-pattern categoryAnti-pattern

PREFER the use of intValue.isOdd/isEven to check for evenness.

BAD:

bool isEven = 1 % 2 == 0;
bool isOdd = 13 % 2 == 1;

GOOD:

bool isEven = 1.isEven;
bool isOdd = 13.isOdd;