Chris Fillmore
12/31/2021, 4:20 PM@Preview
rendering. This shows up as “Render problem” in the preview pane:
java.lang.NullPointerException: Parameter specified as non-null is null
The parameter referenced in the message is just a text: String
which gets passed to a text composable Text(text = text)
@Composable
fun ShoutoutCard(text: String) {
Card(
modifier = Modifier
.padding(16.dp),
elevation = 2.dp,
) {
Row(
modifier = Modifier.padding(8.dp),
verticalAlignment = Alignment.CenterVertically,
) {
HeartFilledIcon(tint = Color.Red)
Spacer(Modifier.padding(16.dp))
Text(text = text)
}
}
}
@Preview
@Composable
fun ShoutoutCard() {
ShoutoutCard(text = "Chris7!")
}
@Preview
@Composable
fun TestComposable() {
Text(text = "Hello2345 ")
}
• Refresh the preview. Sometimes I have to refresh twice1.1.0-rc01
1.6.10
for my project, but I rolled back to 1.6.0
to see if it made a difference (as 1.6.10 is not known to be compatible with this version of compose). There was no difference in behaviour.
I am more or less able to trivially reproduce this problem. Starting from a “working” state (that is, with my ShoutoutCard
composable and TestComposable
both being previewed, I do the following:
• Comment out TestComposable
• Refresh preview
• Observe NullPointerException
• Uncomment TestComposable
• Refresh preview
• Observe preview works againMichael Paus
12/31/2021, 4:50 PMChris Sinco [G]
01/02/2022, 4:33 AMChris Fillmore
01/07/2022, 12:42 PM