When I set buttonColors on a button, I get this er...
# compose
c
When I set buttonColors on a button, I get this error
Functions which invoke @Composable functions must be marked with the @Composable annotation
Copy code
colors = object : ButtonColors {
    override fun backgroundColor(enabled: Boolean): Color =
        JetsnackTheme.colors.color1

    override fun contentColor(enabled: Boolean): Color =
        JetsnackTheme.colors.color1
}
if I remove that block, then everything compiles fine. Any ideas?
c
you should annotate both functions with
@Composable
c
@Cyril Find
Conflicting overloads: @Composable public open fun backgroundColor
=(
c
are you updating to alpha11 ?
c
Still on alpha10 due to reasons
c
oh ok nevermind
did you try extracting the object as a named class ?
c
I did not. I'm going to try to convince my team to move to alpha11 and then see if it keeps happening. might take a few days though.
Thanks @Cyril Find
👍 1
c
⬆️ by the way in alpha11 the implementation changes a bit, maybe you have some versions incompatibilities ? it looks like this now for me
j
I guess that the easiest way is to use one of the functions from
ButtonDefaults
object, like this:
Copy code
OutlinedButton(
    colors = ButtonDefaults.buttonColors(
        backgroundColor = Color.Black
        ...
    )
)
😮 1
🙏 1
👍 1
c
@Jan Bína thanks. I was unaware of this. Gotta look into ButtonDefault some more to see why i would use that over the other possible solution.
@Jan Bína that worked! Thank you!
👍 1