0Pricing
Android Academy · Lesson

State with remember and mutableStateOf

Hold UI state in composables.

What Is State?

State is any value that can change over time and that the UI should react to — a counter, a text field's contents, whether a checkbox is on. When state changes, Compose redraws.

mutableStateOf

mutableStateOf creates an observable value. When you write to it, Compose knows to re-run any composable that read it.

val count = mutableStateOf(0)
// read with count.value, write with count.value = 1

All lessons in this course

  1. State with remember and mutableStateOf
  2. Recomposition Explained
  3. State Hoisting
  4. rememberSaveable
← Back to Android Academy