android5-2 Exercise 2: removeNote ============================== In NotesViewModel: fun removeNote(note: String) { _uiState.update { it.copy(notes = it.notes - note) } } Screen: add onRemoveNote: (String) -> Unit to NotesScreen, pass viewModel::removeNote from NotesRoute, and in the list: items(state.notes) { note -> Row { Text(note) Button(onClick = { onRemoveNote(note) }) { Text("Remove") } } } Note: "it.notes - note" removes the first matching note only. If two notes are identical, give notes an id (a data class Note) rather than using strings. Why StateFlow and not MutableStateFlow: the UI should only read the state. If it could write, any composable could change the state without going through the ViewModel, and the single place where state changes (Chapter 1) would be lost. (The private-writable, public-read-only pattern is from the docs; the reasoning is general knowledge.) Code unrun.