https://kotlinlang.org logo
#compose
Title
# compose
r

Ravi

02/04/2022, 4:57 PM
hi, I’m trying to pass string argument in navgraph, its crashing even after encoding more in the thread
Copy code
composable(
            "profile?caption={caption}",
            arguments = listOf(navArgument("caption") {
                type = NavType.StringType
                nullable = true
            })
        ) { .. }
Copy code
val caption = "FirstLine\nSecondLine"
            navController.navigate("profile?caption=${Uri.encode(caption)}")
Copy code
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=<android-app://androidx.navigation/profile?caption=FirstLine%0ASecondLine> } cannot be found in the navigation graph NavGraph(0x0) startDestination={Destination(0x78c6f587) route=Blue}
its crashing due to
\n
present in the string navarg but after encoding its converting
%0A
i

Ian Lake

02/04/2022, 5:07 PM
That code should certainly work fine. Do you mind filing a bug with a sample project that reproduces your issue? https://issuetracker.google.com/issues/new?component=409828&amp;template=1093757
12 Views