Colton Idle
02/10/2021, 2:25 AMMaterialTheme.colors.*
I get an error of "@Composable invocations can only happen from the context of...", but if I just use a string there instead then it works fine, which shows that my @Composable is actually setup correctly. Code snipipets in thread.LazyColumn(content = {
items(
listOf(
"test1",
"test2",
)
) {
Text(text = it.toString())
}
})
This worksLazyColumn(content = {
items(
listOf(
MaterialTheme.colors.primary,
MaterialTheme.colors.onSecondary,
)
) {
Text(text = it.toString())
}
})
This does not work.rnett
02/10/2021, 2:29 AMMaterialTheme
of is @Composable
(because of the ambient). Note that `LazyColumn`'s content
isn't composable, but the `items`'s content is.Colton Idle
02/10/2021, 2:33 AMAdam Powell
02/10/2021, 2:44 AMColton Idle
02/10/2021, 2:44 AMAdam Powell
02/10/2021, 2:45 AMColton Idle
02/10/2021, 2:45 AMAdam Powell
02/10/2021, 2:46 AMColton Idle
02/10/2021, 3:09 AMval list = listOf(
MaterialTheme.colors.primary,
MaterialTheme.colors.onSecondary,
)
and it has the same error.Adam Powell
02/10/2021, 3:11 AM@Composable
function.
val list = listOf(
MaterialTheme.colors.primary,
MaterialTheme.colors.onSecondary,
)
LazyColumn {
items(list) {
// ...
}
}
Colton Idle
02/10/2021, 3:16 AM