Value passed as String should be received as String
Steps to reproduce:-
- Fragment needs to be added as startDestination in NavGraph
- Add a default argument in fragment of string type and default value that contains only digits
3a.If the value is small like "987987", it'll work good.
3b. If the value is around 15 characters ex:- "987987987987987" , it'll be received as "9.8798797E14"
3c. If the value is pretty large around 30 characters, it'll be received as "infinity"
Nav graph version used - 2.5.3
NavGraph
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/home_nav"
app:startDestination="@id/verifyProductFragment">
<fragment
android:id="@+id/verifyProductFragment"
android:name="com.app.fragments.VerifyProductFragment"
android:label="VerifyProductFragment" >
<argument android:name="imeiNo"
app:argType="string"
android:defaultValue="987987987987987"/>
</fragment>
</navigation>
Fragment
class VerifyProductFragment : Fragment() {
private val args by navArgs<VerifyProductFragmentArgs>()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = ComposeView(requireContext()).apply {
setContent {
Log.e("data", args.imeiNo, )
}
}
}
Dependencies
def nav_version = "2.5.3"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation "androidx.navigation:navigation-dynamic-features-fragment:$nav_version"