Skip to content

Instantly share code, notes, and snippets.

@saqib-github-commits
Created May 2, 2023 18:36
Show Gist options
  • Save saqib-github-commits/52c92bed2be72f579d6bab8326c3bcf0 to your computer and use it in GitHub Desktop.
Save saqib-github-commits/52c92bed2be72f579d6bab8326c3bcf0 to your computer and use it in GitHub Desktop.
@Composable
fun RememberCoroutineScopeTestScreen ( ) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
val coroutineScope = rememberCoroutineScope()
var counter by remember { mutableStateOf(0) }
Text(text = counter.toString())
Spacer(modifier = Modifier.height(8.dp))
Button(
onClick = {
coroutineScope.launch {
counter += 1
}
}
) {
Text(text = "Button")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment