Avatar ·

How to get Context in Jetpack Compose? Problem with accessing resources

Hello everyone! I just started learning Jetpack Compose and encountered a problem: I can't get Context inside a @Composable function.\n\nPreviously, when I wrote in the classic Android SDK with XML, I simply called getContext() or this in Activity/Fragment. But in Compose, I don't understand how to do this.\n\nHere's my example. I'm trying to show a Toast when a button is clicked:\n\n```kotlin\n@Composable\nfun MyScreen() {\n Button(onClick = {\n // Need Context for Toast here\n Toast.makeText(???, "Clicked!", Toast.LENGTH_SHORT).show()\n }) {\n Text("Click me")\n }\n}\n```\n\nI tried using LocalContext.current, but it didn't work for me. Please advise how to properly get Context in Jetpack Compose? Do I need to pass it through function parameters? Or is there some built-in