J'essaie d'itérer sur un fichier List
d'objets, pour chacun de ces objets je veux afficher une carte composable. Le problème est que l'on ne peut pas appeler les fonctions composables à partir de l'intérieur de l'objet. list.forEach{}
des crochets.
Le code :
@Composable
fun Greeting(listy : List<SomethingForLater>) {
LazyColumn {
listy.forEach {
//error here
testCard(somethingForLater = it)
}
}
}
@Composable
fun testCard(somethingForLater: SomethingForLater){
val theme = MaterialTheme
Card(shape = theme.shapes.small,backgroundColor = theme.colors.secondary){
Column {
Row {
Text(
text = somethingForLater.task,
modifier = Modifier.padding(start = 5.dp,
top = 3.dp,bottom = 3.dp
),
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
)
}
}
}
}