In compose type safe navigation, I am trying to pass a nullable data class to a screen route class, I am using serializableType generic fun to create typeMap and pass it to the Route class, with isNullableAllowed as true
inline fun <reified T : Any> serializableType(
isNullableAllowed: Boolean = false,
json: Json = Json,
) = object : NavType<T>(isNullableAllowed = isNullableAllowed) {
override fun get(bundle: Bundle, key: String) =
bundle.getString(key)?.let<String, T>(json::decodeFromString)
override fun parseValue(value: String): T = json.decodeFromString(value)
override fun serializeAsValue(value: T): String = json.encodeToString(value)
override fun put(bundle: Bundle, key: String, value: T) {
bundle.putString(key, json.encodeToString(value))
}
}
but still I am getting this error,
java.lang.IllegalArgumentException: Route companyname.data.model.Route.PartValidation could not find any NavType for argument validation of type companyname.domain.model.ValidationItem? - typeMap received was {companyname.domain.model.ValidationItem (Kotlin reflection is not available)=nav_type}