Jetpack Compose Nested Lazycolumn

You can't have nested LazyColumn because you can't have multiple nested vertical scroll.

java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.

But there is a workaround by not using nested composable.

Covert the following

@Composablefun TestScreen() {    LazyColumn() {        items(10) {            Text("Item $it")            TestItem(it)        }    }}@Composablefun TestItem(count: Int) {    LazyColumn {        items(count) {            Text("Test $it / $count")        }    }}


@Composablefun TestScreen() {    LazyColumn() {        (0..9).forEach {           item {            Text("Item $it")          }          TestItem(it)        }    }}fun LazyListScope.TestItem(count: Int) {    items(count) {        Text("Test $it / $count")    }}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.