val rememberedScaffoldState: ScaffoldState = rememberScaffoldState(drawerState)
...
rememberedScaffoldState.drawerState.close()
I get
Copy code
Suspend function 'close' should be called only from a coroutine or another suspend function
how to workaround that??
j
jim
02/10/2021, 5:28 PM
I can only assume your
rememberedScaffoldState.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
oh, I know that scope functions need to be called inside a scope.
Wanted to know why this is important for a function like 'close()'
whats the special need to be inside a scope there?
j
jim
02/10/2021, 5:53 PM
The close function does not return immediately. It triggers a close animation and suspends until that close animation is completed. You do not want to block the UI thread for the duration of the animation, so it must be a non-blocking suspend function.