CustomPainter Path.lineTo() shadow

167 views
Skip to first unread message

Dshah

unread,
Feb 14, 2019, 4:02:30 PM2/14/19
to flutt...@googlegroups.com
I am using CustomPainter where I need to draw line

class ShapesPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final Paint firstPaint = Paint();
    firstPaint.color = const Color.fromARGB(255, 236, 0, 140);

    final Path firstPath = Path();
    firstPath.lineTo(size.width, 0);
    firstPath.lineTo(0, size.height * 0.10);
    firstPath.close();
    canvas.drawShadow(firstPath, Colors.black87, 2.0, false);
    canvas.drawPath(firstPath, firstPaint);
 }
}
I need to leave margin around the screen so I am using margin in container:
........
Container(
          color: Colors.white,
          margin:
              EdgeInsets.only(top: 60.0, bottom: 20.0, left: 15.0, right: 15.0),
          child: Container(
            child: CustomPaint(
              painter: ShapesPainter(),
              child: Container(
.......

I need to draw shadow under my custom path which I used anvas.drawShadow method in my build Widget, But there is a little shadow also coming over the left side, Please see the image below I pointed an error, Couldn't find any solution for this.

Thanks for any guidance. 
Screenshot 2019-02-14 at 22.50.35 copy.png
Reply all
Reply to author
Forward
0 new messages