https://kotlinlang.org logo
#compose
Title
# compose
k

KotlinLeaner

08/07/2022, 10:49 PM
Another question, I am using compose 1.1.1 in my jetpack compose. I am getting error on my weight modifier. Can someone tell me how can I get my weight modifier in Row?
Copy code
Column {
    Row(
        modifier = Modifier.weight(1f, false)
    ) {
        //...
    }
 }
Error
Expression 'weight' cannot be invoked as a function. The function 'invoke()' is not found
c

Colton Idle

08/08/2022, 6:10 AM
What composable wrap the Row? Is it a column or Row?
k

KotlinLeaner

08/08/2022, 6:18 AM
Its column
I am adding my whole code here please have a look...
Copy code
@Composable
fun Input(optionData: OptionData) {
    Column(
        modifier = Modifier
            .fillMaxSize()
    ) {
        Item(optionData)
    }
}


@Composable
fun Item(optionData: OptionData) {
    /// more item of compose i.e. Text, Textfield
    Submit()
}

@Composable
fun Submit() {
    Row(
        modifier = Modifier.weight(1f, false)
    ) {
        //...
    }
}
j

Johan Reitan

08/08/2022, 11:45 AM
@KotlinLeaner
Modifier.weight()
is defined in
ColumnScope
and
RowScope
. Either use
Modifier.weight()
directly inside your
Column
, or make
Submit
and
Item
extensions of `ColumnScope`:
Copy code
@Composable
fun ColumnScope.Item(...)

@Composable
fun ColumnScope.Submit()
k

KotlinLeaner

08/08/2022, 11:46 AM
Okk got it 👍
Thank you
40 Views