2

It couldn't run successfully with the following error:

Cannot find a parameter with this name: crossAxisSize

How can I fix it? Here's my code:

@Composable
fun NewsStory() {
    Column(
            crossAxisSize = LayoutSize.Expand,
            modifier=Spacing(16.dp)
    )
    {
        Text("demo")
        Text("try")
        Text("somethings")
    }
}
2

2 Answers 2

1

Note - please see an update on this below.

It is available on FlexColumn. Use it inside Column, like this:

 @Preview
@Composable
fun NewsStory() {
    Column( modifier=Spacing(16.dp)) {
        FlexColumn(
            crossAxisSize = LayoutSize.Expand

        )
        {
            Text("demo")
            Text("try")
            Text("somethings")
        }
    }

}

I assume this is the result you want?

This is the result

FlexColumn:

@Composable fun FlexColumn(
    modifier: Modifier = Modifier.None, 
    mainAxisAlignment: MainAxisAlignment = MainAxisAlignment.Start, 
    crossAxisAlignment: CrossAxisAlignment = CrossAxisAlignment.Start, 
    crossAxisSize: LayoutSize = LayoutSize.Wrap, 
    block: FlexChildren.() -> Unit
): Unit

link here

EDIT - Important: Just came to know that Flex is going to be deprecated soon. Oh the joy of working with alpha releases (: So the correct way would be to use Column/Row and apply Flexible modifier to the children. Keeping this post instead of deleting as someone might still be tempted to use FlexColumn/FlexRow as they are still officially out there. Do not!

0

The parameter crossAxisSize was removed from the Column composable, I think in favor of using modifiers. If you want the Column to expand to full size, you can add the Expanded modifier to it, so then your code becomes like this:

@Composable
fun NewsStory() {
    Column(
            modifier=Expanded.wraps(Spacing(16.dp))      <<<------ the change
    )
    {
        Text("demo")
        Text("try")
        Text("somethings")
    }
}

Swapping the two modifiers shouldn't give a different result. You can also use either ExpandedWidth or ExpandedHeight if you only want to expand in one direction (as crossAxisSize actually only expands the width in case of a FlexColumn).

1
  • Thanks. Column(modifier = ExpandedWidth){} seems the most straightforward replacement
    – rockgecko
    Commented Jan 6, 2020 at 5:39

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.