Is there difference between passing composable emp...
# compose
a
Is there difference between passing composable emptyContent VS null ?
Copy code
@Composable
fun SomeComposable(content : @Composable (() -> Unit)? = null) {}
Copy code
@Composable
fun OtherComposable(content : @Composable () -> Unit = emptyContent()) {}
a
Use nullable parameters if the composable needs to test the parameter's value and behave differently if the parameter is null. Comparing against
emptyContent()
isn't reliable for such use cases.
If you don't need this kind of branching behavior, prefer
emptyContent()
and non-nullable.
The difference between the two in the function signature sets expectations for the caller.
a
I see. Thanks