The small task details screen should correctly survive recreation when the configuration changes.
Requirements
- The screen receives a list of tasks and the selected
taskId.
- After recreation, the selected task must be restored by
taskId, not by the list index.
- The title and status on the screen must reflect the currently selected task.
- When the list changes while the screen is alive, the selection state must not "jump" to another item.
- The code must remain within the main ViewModel +
StateFlow + Compose architecture.
Reproduction
- Open the screen with three tasks, where the task with
id = 2 is selected.
- Rotate the device or recreate the
Activity.
- Update the task set so that the order changes, for example:
[(1, "Draft"), (2, "Review"), (3, "Done")]
->
[(3, "Done"), (2, "Review"), (1, "Draft")]
- Observe which task is shown as selected.
Expected behavior
- After recreation, the screen continues to show the task with the same
taskId.
- After reordering elements, the selected task does not change to the neighboring one by position.
- If the
taskId is missing from the new list, the screen should explicitly switch to the "not selected" state rather than showing someone else's data.