0

is there any way I could add a border to this shadowed paint instance below?

I tried to add a stroke with color but it can't paint both of them at the same time!

Code:

class MyPainter extends CustomPainter {
  final Shadow shadow;
  final CustomClipper<Path> clipper;

  MyPainter({
    required this.shadow,
    required this.clipper,
  });

  @override
  void paint(Canvas canvas, Size size) {
    final paint = shadow.toPaint();
    final path = clipper.getClip(size).shift(shadow.offset);
    canvas.drawPath(path, paint);
  }

  @override
  bool shouldRepaint(MyPainter oldDelegate) => false;

  @override
  bool shouldRebuildSemantics(MyPainter oldDelegate) => false;
}

devmuaz
  • 519
  • 7
  • 18
  • 1
    the easiest way is to call [paint](https://api.flutter.dev/flutter/painting/BoxPainter/paint.html) method, see [here](https://gist.github.com/pskink/bc6e9112b52a73df69a2315945758c42#file-rotated_labels-dart-L218) how it can be used in custom painter (in your particular case you should use `ShapeDecoration`) – pskink Dec 21 '22 at 10:53
  • @pskink didn't work well, could you please explain more in code? it would be awesome – devmuaz Dec 21 '22 at 11:10
  • @pskink Ohh GOD!! literally didn't notice the whole code, Thank you so much im gonna give it a try rn! – devmuaz Dec 21 '22 at 11:18

0 Answers0