firstOrNull()
is a Kotlin extension function that works on kotlin.collections.Iterable<T>
but productDetailsList
is a Java List<ProductDetails>
(from the Play Billing library).
Convert to Kotlin collection first
val firstProduct: ProductDetails? = productDetailsList
?.toList()
?.firstOrNull()