I am trying to Parcelize
a data class. It contains one parameter :
var tokenType: Any? = null
For this variable compiler complains at compile time that :
Type is not directly supported by Parcelize. Annotate the parameter with @RawValue if you want it to be serialized via writeValue()
Though the error is self-explanatory, when I add @RawValue like this:
@RawValue var tokenType: Any? = null
it gives an error :
This annotation is not applicable to the target value parameter
Any hints on how to handle this?
I got the answer to this problem from Kotlang
community. Answer is you can not annotate the variable itself but you have to annotate its type.
So annotating in the following way removes the error :
var tokenType: @RawValue Any? = null
Though do not forget to write serilizer/deserializer for this property manually as it will not be done automatically.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With