I want to know how can we return Column/Row
through lamda function in jetpack compose. I tried something but it giving me error.
PairContent
@Composable
fun PairContent(
bluetoothEnable: (ColumnScope) -> Unit,
) {
AnimatedVisibility(visible = true) {
Scaffold {
Column { columnScope ->
bluetoothEnable(columnScope)
}
}
}
}
Error
Type mismatch.
Required:
ColumnScope.() → Unit
Found:
ColumnScope.(Any?) → Unit
Cannot infer a type for this parameter. Please specify it explicitly.
Error in image
CodePudding user response:
ColumnScope should be receiver of your parameter bluetoothEnable: ColumnScope.() -> Unit
@Composable
fun PairContent(
bluetoothEnable: @Composable ColumnScope.() -> Unit,
) {
AnimatedVisibility(visible = true) {
Scaffold {
Column {
bluetoothEnable()
}
}
}
}