What’s the common way of dealing with infinity whe...
# compose
m
What’s the common way of dealing with infinity when deriving new constraints from existing ones? I’m creating a custom layout where I need to leave some space. I am currently doing this:
Copy code
val derivedConstraints = Constraints(minWidth = someWidth,
                                     maxWidth = someWidth,
                                     minHeight = (constraints.minHeight - verticalSpace).coerceAtLeast(0),
                                     maxHeight = (constraints.maxHeight - verticalSpace).coerceAtLeast(0))
But obviously this will end up doing the wrong math when
constraints.maxHeight === Constraints.Infinity
. Do I really have to explicitly check for infinity in such cases, or am I missing something?
🦻 1
e
Copy code
constraints
    .copy(minWidth = someWidth, maxWidth = someWidth)
    .offset(vertical = -verticalSpace)