How can I return to the root Fragment using the NavController
?
I tried
navController.popBackStack(navController.graph.startDestination, false)
but it did not work. This did work:
navController.navigate(navController.graph.startDestination, false)
navController.popBackStack(0, false)
but I'm wondering if this is a proper way to solve this problem.
Use Up or Back button to go to a previous step of the order flow.
How do I get rid of current fragment navigation component? You add to the back state from the FragmentTransaction and remove from the backstack using FragmentManager pop methods: FragmentManager manager = getActivity(). getSupportFragmentManager();
you can use this method, but your arguments are wrong, The first argument is the ID of destination, for back to root you have to use:
findNavController().popBackStack(R.id.Dashboard, false)
Where Dash is the ID of view on your navigation graph
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With