Compose Modifier

onSizeChanged

Invoked with the size of the modified Compose UI element when the element is first measured or when the size of the element changes.

OnSizeChangedSample

@Composable
fun OnSizeChangedSample(name: String) {
    // Use onSizeChanged() for diagnostics. Use Layout or SubcomposeLayout if you want
    // to use the size of one component to affect the size of another component.
    Text(
        "Hello $name",
        Modifier.onSizeChanged { size -> println("The size of the Text in pixels is $size") },
    )
}