roundTo method

int roundTo(
  1. int decimals
)

Rounds this integer to the nearest value.

Note: For integers, this returns the same value unless decimals is 0 or negative.

Example:

int value = 123;
value = value.roundTo(0); // 123

Implementation

int roundTo(int decimals) => decimals <= 0 ? this : this;