Thread
#compose
    orangy

    orangy

    1 year ago
    Is there a reason
    Layout
    composable function has
    content
    parameter first and not last, so it would allow for container-like invocation?
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    1 year ago
    You can specify the parameters in whatever order you want if you name them
    Javier

    Javier

    1 year ago
    but that forces to specify all names except content one to get the container invocation
    orangy

    orangy

    1 year ago
    I can’t invoke it like
    Layout(measureBlocks) { … }
    in named parameters form
    Oh, I got it. Confused by a different overload.
    MeasureBlock
    is a lambda typealias
    Adam Powell

    Adam Powell

    1 year ago
    yes, the intended usage here is for implementing a custom layout composable, e.g.:
    @Composable fun MyLayout(
      modifier: Modifier = Modifier,
      content: @Composable () -> Unit
    ) = Layout(content, modifier) { measurables, constraints ->
      // measure logic here
      layout(myWidth, myHeight) {
        // placement logic here
      }
    }
    so the measure/layout DSL block gets the trailing lambda position