I have pairs value and want to use in vararg. The value is something like this answer
val verticalBrush2 = Brush.verticalGradient(
0.25f to Color.Blue,
1f to Color.Red,
)
I have some business logic to use different colors. So I converted into like this
val brushColors = listOf(0.25f to Color.Blue, 1f to Color.Red)
Now I passed in drawLine brush parameter which is type of vararg. I followed this answer to convert into toTypedArray().
drawLine(
brush = Brush.verticalGradient(
listOf(0.25f to Color.Blue, 1f to Color.Red)
.map { it }
.toTypedArray()
),
start = Offset(x = 0F, y = 0F),
end = Offset(x = 0F, y = size.height),
strokeWidth = 3.dp.toPx(),
)
But still gives me error
