abs method

num? abs()

The absolute value of this number.

The absolute value is the value itself, if the value is non-negative, and -value if the value is negative.

Integer overflow may cause the result of -value to stay negative.

print(Obj(2).abs()); // 2
print(Obj(-2.5).abs()); // 2.5

Implementation

num? abs() => value?.abs();