coerceAtLeast method

T coerceAtLeast(
  1. T minimumValue
)

Ensures that this value is not less than the specified minimumValue.

Return this value if it's greater than or equal to the minimumValue or the minimumValue otherwise.

print(10.coerceAtLeast(5)) // 10
print(10.coerceAtLeast(20)) // 20

Implementation

T coerceAtLeast(T minimumValue) => this < minimumValue ? minimumValue : this;