```drawImage(imageResource(R.drawable.baseline_men...
# compose
n
Copy code
drawImage(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? Thanks
l
The lambda body of
Canvas
:
Copy code
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:
Copy code
val image = imageResource(R.drawable.baseline_menu_white_18dp)

Canvas {
    drawImage(image)
}
👍 1
☝️ 3