Ali Albaali

    Ali Albaali

    1 year ago
    Is there difference between passing composable emptyContent VS null ?
    @Composable
    fun SomeComposable(content : @Composable (() -> Unit)? = null) {}
    @Composable
    fun OtherComposable(content : @Composable () -> Unit = emptyContent()) {}
    Adam Powell

    Adam Powell

    1 year ago
    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.
    Ali Albaali

    Ali Albaali

    1 year ago
    I see. Thanks