Im trying to pass mPriceModifier with 0.0 value in Bundle. But get this exception
java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Float
mPriceModifier initialize
private var mPriceModifier: Double = 0.0
there is only 1 use for mPriceModifier before it goes to Bundle. Anyway with debug mode it shows 0.0 before put it in.
there is the code for bundle
mBundle.apply {
putFloat("priceModifier", mPriceModifier.toFloat())
}
mNavController.navigate(R.id.action_global_processState, mBundle)
mPriceModifier is NonNullableType. nav_graph also doesnt have “nullable” property for this argument.
Also if i add “if” expression like that
if(mPriceModifier != 0.0){
mBundle.apply{
putFloat("priceModifier", mPriceModifier.toFloat())
}
}
then it will skip this expression but anyway give me this exception
3
Not sure if this is the issue, but I would probably declare the variable as float, therefore I don’t need to convert from double to float while putting the value into the bundle. Try the following and remove this (mPriceModifier.toFloat())
private var mPriceModifier: Float = 0.0f
Moreover, please do check/share how you read the value. The issue could also be there.