please dont marked as duplicate , as the question is slightly different ---> null cannot be cast to non-null type kotlin.collections.MutableList
Can't find a reason to use MutableList
but your issue is incorrect type cast (dataList as MutableList
. This is cause null cannot be cast to non-null type. You can simplify code using class CartAdapter(private val context: Context, private val dataList: ArrayList
and remove var dataList: MutableList
, private val context: Context
and init{}