Nikit Bhandari
04/09/2020, 7:12 PMdrawImage(imageResource(R.drawable.baseline_menu_white_18dp)
, Offset(midX, midY), Paint().apply { color = Color(25, 138, 128) })
When I call the above drawImage
method of Canvas, my build fails with the following error Functions which invoke @Composable functions must be marked with the @Composable annotation
But Canvas already has the @Composable annotation, any clue what I might be missing here?
ThanksLouis Pullen-Freilich [G]
04/09/2020, 7:24 PMCanvas
:
onCanvas: DrawScope.() -> Unit
Is not Composable
, and you are calling imageResource
inside this lambda, which is a Composable
function.
So you will need to write something like:
val image = imageResource(R.drawable.baseline_menu_white_18dp)
Canvas {
drawImage(image)
}