Is there a way to pass a string argument with slash ("/") in Jetpack Compose Navigation?

Viewed 153

I wanted to pass a url string as arguments in jetpack compose navigation. The problem is: the slashs ("/") throws an exception, since the navigation uses the slashes to separate the arguments and doesn't find the correct route.

composable(
    route = "Home/{url}",
    arguments = listOf(
        navArgument("url") {
            type = NavType.StringType
        }
    )
)

Then, if I try to navigate, it throws an exception:

val url = "random.com/get/object"
navController.navigate("Home/${url}")
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/Home/random.com/get/object } cannot be found in the navigation graph NavGraph

Is there a way to pass a string argument with slash ("/") in Jetpack Compose Navigation?

0 Answers
Related