Search code examples
navigationandroid-jetpack-compose

Jetpack Compose: Get actual route of nav w/ arguments


I want to retrieve the current route of my nav controller with arguments. If i call navController.currentBackStackEntry?.destination?.route, i do not receive the arguments, but a placeholder like so: chat/{id}, whereas i would like chat/127436112.


Solution

  • You can use:

    navController.currentBackStackEntry?.arguments?.getString("yourArgumentName"))
    

    to retrieve value of the argument.