Hi, based on codelabe on Modifiers :arrow_down: &g...
# compose
c
Hi, based on codelabe on Modifiers ⬇️
Note : By convention, the modifier is specified as the first optional parameter of a function. This enables you to specify a modifier on a composable without having to name all parameters.
Is there a reason why the AppTopBar Modifier was not put as the first parameter in the compose material TopAppBar implementation ?
Copy code
@Composable
fun TopAppBar(
    title: @Composable () -> Unit,
    modifier: Modifier = Modifier,
    navigationIcon: @Composable (() -> Unit)? = null,
    actions: @Composable RowScope.() -> Unit = {},
    backgroundColor: Color = MaterialTheme.colors.primarySurface,
    contentColor: Color = contentColorFor(backgroundColor),
    elevation: Dp = TopAppBarElevation
) {...}
m
I believe that the convention is that
modifier
is the first parameter in the parameter list with a default value. That fits with the
TopAppBar()
code that you pasted in, as
title
does not offer a default value.
2
c
I now understand better, thank you.