Is there a way to obtain Context
within a LaunchedEffect
?
I need to call a certain function which needs the reference of Context
object in order to execute.
I cannot use LocalContext.current
, because:
@Composable invocations can only happen from the context of a @Composable function
CodePudding user response:
You can get context value in view builder context and then use it in LaunchedEffect
:
val context = LocalContext.current
LaunchedEffect(context) {
context
}