Hi. How do you pass strings, which contains # or ?...
# compose
g
Hi. How do you pass strings, which contains # or ?, to navController.navigate? Currently the text is treated as url, so if I have an id like username#123 then on second screen I receive only "username"
One idea I have is to encode this string as Base64 and decode it on the second screen, but this seems extra logic
j
You URL encode them (i.e., percent escape)
๐Ÿ“Œ 1
i
Don't do any of this, use the type safe APIs which just have a Serializable object with a string property and we'll do the rest: https://medium.com/androiddevelopers/navigation-compose-meet-type-safety-e081fb3cf2f8
๐ŸŒŸ 2
๐Ÿ“Œ 3
๐Ÿš€ 2
๐Ÿ”ฅ 2
๐ŸŽ‰ 4
๐Ÿ’ฏ 2
jetpack compose 3
g
thanks for repply, I will read it and try
man, this is one of this changes I want to stare at the code because it looks so nice
Copy code
composable(
                "$PLAYER_STATS/{$PLAYER_TAG}/{$PLAYER_BACKGROUND}",
                arguments = listOf(navArgument(PLAYER_TAG) { type = NavType.StringType }),
            )
is now just
Copy code
composable<PlayerStats> { }
๐Ÿ”ฅ 2
๐Ÿ”ฅ