Reputation: 7271
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
Upvotes: 2
Views: 1915
Reputation: 67189
ColumnScope should be receiver of your parameter bluetoothEnable: ColumnScope.() -> Unit
@Composable
fun PairContent(
bluetoothEnable: @Composable ColumnScope.() -> Unit,
) {
AnimatedVisibility(visible = true) {
Scaffold {
Column {
bluetoothEnable()
}
}
}
}
Upvotes: 5