I have real-time data values painted as a graph from left to right in flutter. Its a lot of source data but very simple: Vertical lines canvas.drawLine(from here, to here) from a realtime list of doubles drawing from left to right across the screen.
After the screen is full I want to completely discard the painted information and draw again from left to right.
I've 'functionally' accomplished this by drawing the graph then drawing a black box over the top of the canvas and drawing again however this is totally non-performant. Within a minute performance degrades and memory starts swapping out to cache. The information is obviously being kept.
I'd appreciate specific advice on the following please guys:
- Best practice for clearing a canvas from inside a custom paint where the actual information gets disposed and the overall cache/memory usage of the canvas thus remains bounded.
- If this isn't possible, any of the most performant work arounds you can think of.