'Jetpack compose TopAppBar gives a call error

I get an error when I write the following in Jetpack compose TopAppBar. I think it's a rudimentary mistake, but I don't know. write error

TopAppBar( // ← error:None of the following functions can be called with the arguments supplied.
    title = Text(text = "hogrhoge"),
    actions = {IconButton(...)}


Solution 1:[1]

Parameter title is of type @Composable () -> Unit, which means you have to pass composable function there. You are instead passing value returned from Text function, which is Unit. And it's the same with actions parameter. What you should do is this:

TopAppBar(
    title = { Text(...) },
    actions = { IconButton(...) },
    ...
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jan Bína