constrainWidth

Function

Common
fun Constraints.constrainWidth(width: Int) = width.fastCoerceIn(minWidth, maxWidth)

Takes a width and returns the closest size to it that satisfies the constraints.