Sayali N
06/26/2023, 8:20 PMJeff Lockhart
06/26/2023, 10:40 PMsuspend
function from Compose, you should use rememberCoroutineScope()
to get a CoroutineScope
bound to the composable's lifecycle. Then launch a coroutine and call the suspend
function in it. See docs. You should also become familiar with coroutines and how they work.
As for the other error:
@composable invocations can only happen from the context of a @composable functionAre you trying to call a function annotated with
@Composable
from within your onClick
handler? Composable functions should only be used to compose your UI (or within other compose hierarchies). You shouldn't be calling from an event handler.