How to make custom arrow shape in flutter?

205 views Asked by At

In my flutter app I have to create custom shaped arrows like bellow images,

enter image description here

And

enter image description here

So how I can create arrow like shown in this image?

Thank you...

1

There are 1 answers

2
Manoj Padia On
class ArrowClipper extends CustomClipper<Path> {
  const ArrowClipper({this.addBackArrow = false});

  final bool addBackArrow;

  @override
  Path getClip(Size size) {
    final path = Path();

    double arrowWidth = size.height / 2; // Adjust the proportion of arrow height

    path.lineTo(size.width - arrowWidth, 0.0);
    path.lineTo(size.width, size.height / 2);
    path.lineTo(size.width - arrowWidth, size.height);
    path.lineTo(0.0, size.height);
    if (addBackArrow) {
      path.lineTo(arrowWidth, size.height / 2);
    }
    path.close();

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) {
    return true;
  }
}

Output:

enter image description here