I have the following nested graph:
@Serializable private data object Onboarding
@Serializable private data object OnboardingScreen1
@Serializable private data object OnboardingScreen2
@Serializable private data object OnboardingScreen3
@Serializable private data object OnboardingScreen4
navigation<Onboarding>(
startDestination = OnboardingScreen1,
) {
composable<OnboardingScreen1> {}
composable<OnboardingScreen2> {}
composable<OnboardingScreen3> {}
composable<OnboardingScreen4> {}
}
I know that I can use navHostController.navigate(Onboarding)
to navigate to that graph and then the startDestination, in my case OnboardingScreen1
will be opened. From 1 you can navigate to 2, from 2 to 3 and so on.
How can I pre build the navigation stack though? Let’s say the user opens the app again and then I want to restore where the user was last time and then you should start already on OnboardingScreen3
and if you press back you end up on 2, etc?
1