fluttercustom-painting

Flutter : Custom Painter draw path with different fill and stroke color


I am using the CustomPainter to draw a line chart where the line(stroke) needs to be of a different color and the fill color should be a different shade of it. I could draw the chart but both with same colors. However, I need the colors to be different. How can I do this with a CustomPainter?

Also, I want to know how to have a single path painted with different colors instead of a single color if possible.

Thanks for your help!


Solution

  • I personally draw the stroke with "drawLine" calls and the fill with "drawPath".

    You can define 2 different paints and use paint1 with "drawLine" and paint2 with "drawPath".