Fixed
Status Update
Comments
cl...@google.com <cl...@google.com>
ap...@google.com <ap...@google.com> #2
Please include a sample project that reproduces your issue.
cl...@google.com <cl...@google.com> #3
na...@google.com <na...@google.com> #4
Maybe it is the same as the other issue I listed? Different use case but same root cause?
zy...@gmail.com <zy...@gmail.com> #5
Switching to Kotlin Safe Args fixed the issue, so seems like the same issue, just on the Directions side (vs the other which is on the Args side).
Description
Component used: Navigation
Version used: 2.8.5
The attempts to fill in the
NavDestination.fillInLabel
methodlabel
of theNavDestination
with arguments. However, it does this by (in every case butNavType.ReferenceType
) by just callingargs[argName].toString()
- e.g., just directly callingtoString()
on the object in theSavedState
bundle.While this approach works for simple types, a custom
NavType
might not store their class directly in the Bundle - for example, if using the@Serializable
support, it would be stored as aBundle
, which means thetoString()
is unlikely to actually be what is needed.Instead,
fillInLabel
should take into account theNavType
and use itsget
method to give theNavType
control over exactly the object that is synthesized from the arguments. That way, developers could implement a customtoString()
implementation on their object to control how it is displayed in the label.