https://kotlinlang.org logo
#compose
Title
# compose
w

willyrs

04/09/2022, 9:08 PM
Hello, I've just started with compose and I have a strange error.. "Composition requires an active composition context" while drawing my UI. This is the main activity:
Copy code
setContent {
    MyTheme {
        Surface(color = MaterialTheme.colors.background) {
            Column(Modifier.fillMaxHeight()) {
                ListComposable(getList())
            }
        }
    }
}
The ListComposable:
Copy code
@Composable
fun ListComposable(list: List<Info>, modifier: Modifier = Modifier) {
    LazyColumn(modifier) {
        items(items = groupedList, itemContent = { item ->
            Text(item.value) // CRASH HERE
        })
    }
}
I don't understand what's happening.. If I pass an empty list, it works. When it's non empty it crashes. The Info is a simple data class with just a value
Damn I got it.. I was importing Text from ui-framework instead of Material...
c

Chris Sinco [G]

04/09/2022, 11:39 PM
Hmm surprised lint didn't pick that up. Was there no squiggly underneath the Text element before in the editor?