Dirk Hoffmann
02/10/2021, 4:54 PMval rememberedScaffoldState: ScaffoldState = rememberScaffoldState(drawerState)
...
rememberedScaffoldState.drawerState.close()
I get
Suspend function 'close' should be called only from a coroutine or another suspend function
how to workaround that??jim
02/10/2021, 5:28 PMrememberedScaffoldState.drawerState.close()
is occurring within an onclick handler, not in your composable function, right? It's unclear from your code snippet, but calling it from a composable function would be very wrong.
To answer your question though, you will probably need to launch
it into a coroutine scope. https://kotlinlang.org/docs/reference/coroutines/basics.html
You can get a coroutine scope something like this:
@Composble fun demo() {
val scope = rememberCoroutineScope()
Button(
onClick={
scope.launch { drawerState.close() }
}
)
}
Dirk Hoffmann
02/10/2021, 5:47 PMjim
02/10/2021, 5:50 PMDirk Hoffmann
02/10/2021, 5:51 PMjim
02/10/2021, 5:53 PM