Application throws an IllegalStateException with LazyColumn, but I have no nested scroll content

29 views Asked by At

When navigating from the Settings screen to the Language screen, which contains one LazyColumn of three rows, it throws this exception:

IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed

If anyone can give advice.

val listState = rememberLazyListState()
    var selectedIndex by remember{ mutableIntStateOf(-1) }

    Card(
        modifier = Modifier
            .fillMaxWidth(),
        shape = RoundedCornerShape(15.dp),
        colors = CardDefaults.cardColors(
            containerColor = MaterialTheme.customColorsPalette.cardContainer
        ),
        elevation = CardDefaults.cardElevation(8.dp)
    ) {
        LazyColumn(state = listState) {
            items(items = list) { language ->
                LanguageRowItem(
                    onClick = {
                        selectedIndex = if (selectedIndex != language.id)
                            language.id else -1
                        tag = language.tag
                        onClickRefreshActivityEnglish()
                    },
                    title = language.title,
                    chosen = language.id == selectedIndex
                )
            }
        }
    }
@Composable
fun LanguageRowItem(
    onClick: ()-> Unit, title: String, chosen: Boolean
) {
    Card(
        modifier = Modifier.fillMaxWidth(),
        shape = RectangleShape,
        colors = CardDefaults.cardColors(
            containerColor = Color.Transparent
        ),
        onClick = { onClick() }
    ) {
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(15.dp),
            verticalAlignment = Alignment.CenterVertically
        ) {
            Text(
                modifier = Modifier,
                text = title,
                style = TextStyle(
                    color =
                    if (chosen) MaterialTheme.colorScheme.primary
                    else MaterialTheme.customColorsPalette.blackToWhite,
                    fontWeight = FontWeight.SemiBold,
                    fontSize = 18.sp
                )
            )
        }
    }
}
0

There are 0 answers