Rene Win
02/21/2022, 7:20 AMColumn {
Box {
AnimatedVisibility(visible = true) {
Text("test")
}
}
}
This results into an error:
'fun ColumnScope.AnimatedVisibility(visible: Boolean, modifier: Modifier = ..., enter: EnterTransition = ..., exit: ExitTransition = ..., label: String = ..., content: AnimatedVisibilityScope.() -> Unit): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary
The provided fix from IDE is to annotate the AnimatedVisibility with
Column {
Box {
this@Column.AnimatedVisibility(visible = true) {
Text("test")
}
}
}
Then everything works fine. The question is why is this necessary? Is this the correct fix? Why cant I call this composable like every other composable?Adrijan Rogan
02/21/2022, 7:39 AMColumnScope
.
The "normal" function: https://developer.android.com/reference/kotlin/androidx/compose/animation/package-summary#AnimatedVisibility(kotlin.B[…]lin.String,kotlin.Function1)
The column scope extension function: https://developer.android.com/reference/kotlin/androidx/compose/animation/package-summary#(androidx.compose.foundatio[…]lin.String,kotlin.Function1)
AnimatedVisibility
inside a box should probably use the non-extension function. Make sure to select the correct AnimatedVisibility
function when using autocomplete, although I believe it should automatically pick the correct one.Albert Chang
02/21/2022, 7:45 AMColumnScope
is not actually accessible there. The AnimatedVisibility
function without a receiver is what you should use. You can extract the AnimatedVisibility
to a new function. Using the fully qualified name androidx.compose.animation.AnimatedVisibility
also seems to fix the problem.Rene Win
02/21/2022, 7:50 AM