measure

fun measure(c: ComponentContext, widthSpec: Int, heightSpec: Int, outputSize: Size)

Measure a component with the given SizeSpec constraint.

Delicate API: This API is delicate as it can lead to undefined behaviors when called during resolve. The method should be used strictly during **layout**, otherwise, an IllegalStateException will be thrown when measureInResolvePolicy is set to CRASH

To avoid this issue, use the RenderWithConstraints API for Kotlin Components, which defers component creation until layout phase. As such, it provides SizeConstraints that can be used directly, and if needed, a safe API to measure child components. For LayoutSpec components that need to measure their children, the @OnCreateLayoutWithSizeSpec annotation should be used instead.

Parameters

widthSpec

Width SizeSpec constraint.

heightSpec

Height SizeSpec constraint.

outputSize

Size object that will be set with the measured dimensions.

Throws

if called during the resolve phase and measureInResolvePolicy is set to CRASH.


fun measure(c: ComponentContext, widthSpec: Int, heightSpec: Int, outputSize: Size, shouldCacheResult: Boolean)

Measure a component with the given SizeSpec constraint.

Delicate API: This API is delicate as it can lead to undefined behaviors when called during resolve. The method should be used strictly during **layout**, otherwise, an IllegalStateException will be thrown when measureInResolvePolicy is set to CRASH

To avoid this issue, use the RenderWithConstraints API for Kotlin Components, which defers component creation until layout phase. As such, it provides SizeConstraints that can be used directly, and if needed, a safe API to measure child components. For LayoutSpec components that need to measure their children, the @OnCreateLayoutWithSizeSpec annotation should be used instead.

Parameters

widthSpec

Width SizeSpec constraint.

heightSpec

Height SizeSpec constraint.

outputSize

Size object that will be set with the measured dimensions.

shouldCacheResult

Whether the measurement result should be cached for future use.

Throws

if called during the resolve phase and measureInResolvePolicy is set to CRASH.