use_is_even_rather_than_modulo

Group: style

Maturity: stable

Dart SDK: >= 2.9.0 • (Linter v0.1.116)

Since info is static, may be stale

View all Lint Rules

Using the Linter

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;

Usage

To enable the use_is_even_rather_than_modulo lint, add use_is_even_rather_than_modulo under linter > rules in your analysis_options.yaml file:

linter:
  rules:
    - use_is_even_rather_than_modulo