Created
July 5, 2022 20:36
-
-
Save lucas-marciano/498d88293f6a8dc9ea5b01a94d59d5ab to your computer and use it in GitHub Desktop.
Exemplo do uso do remember com elevação do controle de estado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun HelloScreen() { | |
var name by rememberSaveable { mutableStateOf("") } | |
HelloContent(name = name, onNameChange = { name = it }) | |
} | |
@Composable | |
fun HelloContent(name: String, onNameChange: (String) -> Unit) { | |
Column(modifier = Modifier.padding(16.dp)) { | |
Text( | |
text = "Hello, $name", | |
modifier = Modifier.padding(bottom = 8.dp), | |
style = MaterialTheme.typography.h5 | |
) | |
OutlinedTextField( | |
value = name, | |
onValueChange = onNameChange, | |
label = { Text("Name") } | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment