Skip to content

Instantly share code, notes, and snippets.

@lucas-marciano
Created July 5, 2022 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucas-marciano/498d88293f6a8dc9ea5b01a94d59d5ab to your computer and use it in GitHub Desktop.
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
@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