https://kotlinlang.org logo
#compose
Title
# compose
t

Tin Tran

02/18/2022, 5:45 AM
On compose 1.2.0-alpha03 writing this give me a compilation error saying
@Composable invocations can only happen from the context of a @Composable function
. It wasn’t the case in 1.1.0. Is this expected?
Copy code
buildAnnotatedString{
    withStyle(SpanStyle(....)){
        append(" • ${stringResource(key = "key", defaultValue = "Open now")}") //won't compile
    }
}
buildAnnotatedString {
    append(stringResource(key = "key", defaultValue ="Work time")) //compile
}
j

Jiří Červený

03/09/2022, 1:09 PM
Hi, do you find out what’s the problem here?
s

ste

03/12/2022, 5:35 PM
It looks like a bug, is there a filed issue yet?
Meanwhile you can just:
Copy code
val index = pushStyle(SpanStyle(....))
append(" • ${stringResource(key = "key", defaultValue = "Open now")}")
pop(index)
t

Tin Tran

03/14/2022, 2:49 AM
I reverted to 1.1.1 so I don’t know If this is fixed on latest compose yet. I will check later this day if it’s still an issue I’ll file a bug
o

Oleksandr Balan

03/15/2022, 9:24 AM
7 Views