I'm having an issue with a preview not rendering, ...
# compose
g
I'm having an issue with a preview not rendering, I have a data class that stores a refernce to a drawable, as part of the preview I'm creating some dummy data and referencing real drawables, but the preview complains that the drawables don't exist, see 🧵
Copy code
@Preview("Player list without buttons", showBackground = true)
@Composable
private fun PlayersSansButton() {
    SushiGOScoreTrackerTheme {
        PlayerList(
            players = listOf(
                Player(id = "1", name = "Gabriel", avatar = R.drawable.egg_nigiri),
                Player(id = "2", name = "Emma", avatar = R.drawable.salmon_nigiri),
                Player(id = "3", name = "SpacedMonkey", avatar = R.drawable.squid_nigiri),
                Player(id = "4", name = "Maja", avatar = R.drawable.maki),
                Player(id = "5", name = "Aleksandra", avatar = R.drawable.wasabi),
            ),
            addPlayer = { },
            canAddPlayers = true
        )
    }
}
Copy code
android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F07006F.
Copy code
@Immutable
data class Player(
    val id: String,
    val name: String,
    val avatar: Int,
    val score: Int = 0,
    val wins: Int = 0,
)
and it's utilised:
Copy code
Image(
    painter = painterResource(player.avatar),
    contentDescription = "avatar",
    modifier = Modifier
        .weight(3f)
        .padding(5.dp)
)