Status Update
Comments
il...@google.com <il...@google.com> #2
Thanks for filing an issue - this is the best way to ensure that we see the issue and can fix it for everyone.
I believe you're the poster ofhttps://www.reddit.com/r/androiddev/comments/b0kgmt/safeargs_gotcha_when_using_nullable_args/ , which we did see and we're already working on a fix, so I'll mark this as a duplicate of the issue we filed on behalf of you.
I believe you're the poster of
ks...@gmail.com <ks...@gmail.com> #3
My apologies for not checking before reporting this issue. Thanks for reporting it! I'm glad to see a fix for this has landed to the latest beta.
Description
Version used: 1.0.0
Devices/Android versions reproduced on: Google Pixel, Android 9
Suppose you have a nav graph like this for a fragment MyFragment.kt
```
<fragment>
...
<argument
android:name="anArg"
app:argType="string"
app:nullable="true"
android:defaultValue="@null"/>
</fragment>
```
In MyFragment.kt, get nav args like this:
```
class MyFragment: Fragment {
private val myArgs: MyFragmentArgs by navArgs()
}
```
When this fragment is started without any arguments (such as from a BottomNavView) then:
Expected Behaviour: `myArgs` is a bundle, where `myArgs.anArg` is null
Actual Behaviour: `myArgs` is null.
What's worse is that the `navArgs()` delegate function throw an exception and crashes the app if the given arguments bundle is null.
Actual code and screen recording can be found on this Github issue: