implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
kotlin
val navController = findNavController(R.id.nav_host_fragment)
val navInflater = navController.navInflater
val graph = navInflater.inflate(R.navigation.nav_graph)
val destination = FragmentNavigator(fragment.requireContext()).createDestination()
destination.id = R.id.new_fragment
destination.className = "com.example.NewFragment"
graph.addDestination(destination)
graph.startDestination = R.id.new_fragment
navController.graph = graph
kotlin
val bundle = Bundle()
bundle.putString("key", "value")
navController.navigate(R.id.destination_fragment, bundle)
kotlin
navController.safeNavigate(R.id.destination_fragment) {
arguments = bundleOf("key" to "value")
}