is composable(arguments = listOf(navArgument("item...
# compose
b
is composable(arguments = listOf(navArgument("itemId") { type = NavType.IntType }), just used for mapping an argument type to something other than a string? I noticed that when my argument is a string and I keep it as a string it still works without specifying arguments.
i.e. this still worked even when arguments were commented out. fun NavController.navigateToCustomers(customerId: String? = null) { val route = if (customerId != null) { "customers?customerId=$customerId" } else { "customers" } this.navigate(route) }
Copy code
composable(
            route = "customers?customerId={customerId}",
//            arguments = listOf(navArgument("customerId") {
//                type = NavType.StringType
//                nullable = true
//            })
        ) {
            val customerId = it.arguments?.getString("customerId")
            Scaffold {
                Box(modifier = Modifier.padding(it)) {
                    Text("Customer ID: ${customerId ?: "No customer ID provided"}")
                }
            }
        }
s
StringType is indeed the default type if you specify nothing
👀 1
b
Oh cool, yeah that makes sense. I'm just going to make a good habit out of always specifying the arguments, but yeah I was surprised to see it working without it.
s
Yeah I would not rely on defaults either. I’d definitely specify the type as well.