hey guys, does anyone know if Column offers a way ...
# compose
h
hey guys, does anyone know if Column offers a way to check if there’s enough content for scroll, for example 3 items will not be scrollable in portrait but will be in landscape?
t
I only know of a workaround using ScrollState:
Copy code
val scrollState = rememberScrollState()
val showScrollbar by scrollState.scrollingNeeded 

Column(Modifier.verticalScroll(scrollState)) {
    ...
}

if (showScrollbar) {
    VerticalScrollBar(...)
}

val ScrollState.scrollingNeeded get() = derivedStateOf {
    maxValue > 0 && maxValue < Int.MAX_VALUE
}
ScrollState.maxValue
seems to represent the missing space to show all content, i.e. it is greater than 0 when the viewport is too small (and Int.MAX_VALUE when still unkown).
h
Copy code
val scrollState = rememberScrollState()

    val canScroll= (scrollState.canScrollForward || scrollState.canScrollBackward)