I'm trying to use Canvas in compose, and am seeing what looks like old state in my DrawScope. I sort of expected that the canvas would be cleared each time. Is there a way for me to clear the draw scope, so that it just repaints the whole canvas?
This turned out to be several errors in my code. Something I thought would change, didn't. And the flow of state I was expecting to work, didn't work. Getting that all out of the way, I am seeing expected updates to the Canvas.
2 years ago
Typically composables will redraw during composition or if there is a state change on a parameter that is being read during the DrawScope lambda. In compose, there are observations to state parameters made at various lifecycle steps, (measurement/layout/draw) and anytime a state parameter is changed that is read in those steps, that step is re-executed.