Not sure if this was discussed already
data class MyNavArgs(
...
val myBoolean: Boolean = null,
)
AI summary:
- booleanNavType is typed as DestinationsNavType<Boolean?> (nullable)
- When a Boolean nav arg has a default value (= false), KSP
correctly sets defaultValue = false in the navArgument block
- But in the generated argsFrom(bundle) method, it generates:
myBoolean = booleanNavType.safeGet(bundle, "myBoolean") ?: throw RuntimeException("... not present!")
- When navigating via deep link (which doesn't include
myBoolean in the URL), the Navigation framework should supply the default, but booleanNavType.safeGet() can return null when the value isn't in the bundle — triggering the crash
Not sure if this was discussed already
AI summary:
correctly sets defaultValue = false in the navArgument block
myBoolean in the URL), the Navigation framework should supply the default, but booleanNavType.safeGet() can return null when the value isn't in the bundle — triggering the crash