Zoltan Demant
09/27/2021, 8:57 AMZoltan Demant
09/27/2021, 8:58 AMval LocalStep = compositionLocalOf<Step> {
    throw NullPointerException()
}
@Composable
fun <T> Property(
    modifier: Modifier = Modifier,
    step: Step = LocalStep.current, //crashes
    input: Input<T>,
    onUpdate: (Input<T>) -> Unit,
    label: String? = null,
    style: InputStyle? = null,
    fill: Boolean = false
) {
    val step = LocalStep.current //works
}adjpd
09/27/2021, 9:04 AMthrow NullPOinterException()Zoltan Demant
09/27/2021, 9:09 AMZoltan Demant
09/27/2021, 9:10 AMCLOVIS
09/27/2021, 11:27 AMZoltan Demant
09/27/2021, 12:29 PMtheapache64
09/27/2021, 12:47 PMcompositionLocaldata class User(val name: String)
val LocalUser = compositionLocalOf<User> { throw NullPointerException() }
@Preview
@Composable
fun A() {
    CompositionLocalProvider(LocalUser provides User(name = "Adam")) {
        Column {
            B()
            C()
        }
    }
}
@Composable
fun B(
    user: User = LocalUser.current
) {
    Text(text = "B says user is ${user.name}")
}
@Composable
fun C(){
    val user = LocalUser.current
    Text(text = "C says user is ${user.name}")
}Zoltan Demant
09/27/2021, 12:59 PM@JvmInline
value class User(val name: String)Zach Klippenstein (he/him) [MOD]
09/27/2021, 3:22 PMPropertyLocalSteptheapache64
09/27/2021, 3:24 PMvaluecompositionLocalZoltan Demant
09/27/2021, 3:44 PMParameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter stepZach Klippenstein (he/him) [MOD]
09/27/2021, 3:59 PMZoltan Demant
09/28/2021, 5:28 AMZach Klippenstein (he/him) [MOD]
09/28/2021, 2:11 PMZach Klippenstein (he/him) [MOD]
09/28/2021, 2:12 PM