Search code examples
android-jetpack-composeandroid-jetpack-navigation

Is there a way to get all the previous destinations before the current destination?


So we can get the destination before the current destination by using NavController.previousBackStackEntry, but I would like to get all the destinations that came before the current destination not just the one before in jetpack compose


Solution

  • You just need to iterate over the backQueue property.

    navController.backQueue.forEach { entry ->
        Log.d("TAG", "${entry.destination.route}")
    }