Is there a recommended convention on defining/pass...
# compose
t
Is there a recommended convention on defining/passing the very ubiquitous modifier arguments? E.g. 1. Always define the modifier first or last? 2. Always pass the modifier argument first or last? 3. Do it wherever you want, just always use modifier =, so it's clear? 4. Something else?
c
idk if this answers all of your questions, but a great artcile by Chris Banes https://chris.banes.me/posts/always-provide-a-modifier/
c
I can’t speak to order but what I’ve been doing more consistently in general is always typing out parameter names to make it clear and not rely on editor inlay hints
s
According to the Compose ktlint rules for example,
Modifier
should be the first parameter of parameters with default values, after the last parameter without a default value. So for example:
Copy code
@Composable
fun MyComposable(
  text: String,
  color: Color,
  modifier: Modifier = Modifier,
  subtitle: String? = null,
) { ... }
t
🙏
That actually makes good sense