clamp method
Clamps this value to the inclusive range from lowerLimit to upperLimit.
Implementation
FdcDecimal clamp(Object lowerLimit, Object upperLimit) {
final lower = _coerceOperand(lowerLimit, operation: 'clamp');
final upper = _coerceOperand(upperLimit, operation: 'clamp');
if (lower > upper) {
throw ArgumentError.value(
upperLimit,
'upperLimit',
'Must be greater than or equal to lowerLimit.',
);
}
if (this < lower) {
return lower;
}
if (this > upper) {
return upper;
}
return this;
}