Skip to content

Instantly share code, notes, and snippets.

@kasem-sm
Last active October 1, 2021 15:02
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 kasem-sm/00a2756179c34cfd558219fe7a41169b to your computer and use it in GitHub Desktop.
Save kasem-sm/00a2756179c34cfd558219fe7a41169b to your computer and use it in GitHub Desktop.
Passing data to next screen via Bundles
// Extension Function
fun Fragment.navigate(@IdRes destination: Int, args: Bundle) {
navigate(destination = destination, args = args)
}
// How To Use?
// post_id is the data you want to pass to the next screen [i.e. an Int, String or any type)
// "key_post_id" is the unique key which would be used to retrive post_id via SaveStateHandle.
navigate(
destination = my_destination.actionId,
args = bundleOf("key_post_id" to post_id)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment