Skip to content

Instantly share code, notes, and snippets.

@KaustubhPatange
Created June 4, 2022 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaustubhPatange/a00f95cbaade83781898513decd01e46 to your computer and use it in GitHub Desktop.
Save KaustubhPatange/a00f95cbaade83781898513decd01e46 to your computer and use it in GitHub Desktop.
// somewhere at the top, create & remember instance of SaveableStateHolder
val saveableStateHolder = rememberSaveableStateHolder()
// called for every destination with a unique key in navigation structure
// (when created or active)
saveableStateHolder.SaveableStateProvider(key = ...) {
// composable content whose rememberSaveable values will be saved with
// the given key
}
// remove the saved state, happens during backward navigation i.e destination
// is removed from the backstack.
saveableStateHolder.removeState(key = ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment