02/15/2023, 4:37 AM
What's the reasoning for the difference between default values for composable lambda parameters like in
where they are nullable, and
where they are empty lambdas?

Stylianos Gakis

02/15/2023, 8:40 AM
You can look at the implementation of it to figure out the difference. Sometimes they use nullable composables so that you can null check it to figure out if you need to do something differently if it exists or not. If you use an empty lambda you wouldn’t know it’s not gonna be there, only that it’s there but then it’d emit no UI. For example look at this line here[…]e/material/OutlinedTextField.kt;l=542-544?q=OutlinedTextField and how they add some padding if the lambda is there at all, it’d look super weird if it was an empty lambda, so the padding was added and there was no actual placeholder.