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

Tiago Nunes

02/25/2022, 10:05 AM
Hi everyone, Can I apply @PreviewParameter to an argument that's a List? e.g.:
Copy code
@Preview
@Composable
fun MenuPreview(
    @PreviewParameter(MenuItemPreviewParameterProvider::class) menuItems: List<MenuItem>
) {
    MdcTheme {
        Menu(menuItems)
    }
}

class MenuItemPreviewParameterProvider : PreviewParameterProvider<MenuItem> {
    override val values = sequenceOf(
        MenuItem("Beer & Other"),
        MenuItem("More"),
        MenuItem("Shop All Products"),
    )
}
I would expect menuItems argument to be a list with the 3 sample values
p

Paul Woitaschek

02/25/2022, 10:13 AM
No, if you expect
List<MenuItem>
you should have a
PreviewParameterProvider<List<MenuItem>>
🙌 1