Question: How to remember state in screen after navigation with Kotlin? I m making an app in Android Studio using Kotlin / Jetpack Compose. The basics
How to remember state in screen after navigation with Kotlin?
Im making an app in Android Studio using KotlinJetpack Compose.
The basics are:
In the Home Screen, the user can click on a district District being an enum class from a dropdown menu, and choose to see the number of votes for each political party from that district.
From the Home Screen, the user can also navigate to a Party Screen by clicking on a Card for a certain political party. This will take them to a Party Screen, where they can read info about that party.
From the Party Screen, the user can navigate back to Home Screen.
When the user navigates back to Home Screen, I want the Home Screen to remember which district the user chose before navigating to Party Screen, so that we still display the votes from that district. However, Im not sure how to do this.
Home Screen and Party Screen use different ViewModels, so Im not sure state hoisting would help here.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
