Challenge 2: A UiState Data Class — Solution data class TodoUiState( val items: List = emptyList(), val isLoading: Boolean = true ) class TodoViewModel : ViewModel() { private val _uiState = MutableStateFlow(TodoUiState()) val uiState: StateFlow = _uiState.asStateFlow() fun addItem(text: String) { _uiState.value = _uiState.value.copy( items = _uiState.value.items + text, isLoading = false ) } } Notes: - _uiState.value.copy(items = _uiState.value.items + text, isLoading = false) creates a brand new TodoUiState with the updated items list and isLoading flag, leaving the original _uiState.value's TodoUiState instance itself completely untouched (data classes built from val properties are immutable — Kotlin Fundamentals Chapter 4). - items + text (list + single element) produces a NEW list containing every existing item plus the new one — this relies on Kotlin Fundamentals Chapter 6's collection operators, not mutation of the existing list in place. - Both fields are updated together in one copy() call, which is exactly what keeps the state internally consistent — there's no possible intermediate moment where isLoading is stale relative to items, because the whole TodoUiState is replaced atomically.