I want to use the Flutter Custom Clipper to create a shape like the picture below, but it doesn’t work. Is there anyone who can help?
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
List<Offset> polygon = [
Offset(0, 10),
Offset(size.width - 30, 10),
Offset(size.width - 25, 0),
Offset(size.width - 20, 10),
Offset(size.width, 10),
Offset(size.width, size.height),
Offset(0, size.height),
Offset(0, 10),
];
Path path = Path()
..addPolygon(polygon, false)
..close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
}
}
[Svg code]
<svg width="132" height="110" viewBox="0 0 132 110" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M111.858 1.73511L111.434 1.05619L111.01 1.73512L107.096 8H5.997C2.96081 8 0.5 10.4627 0.5 13.5V103.5C0.5 106.537 2.96081 109 5.997 109H125.925C128.961 109 131.422 106.537 131.422 103.5V13.5C131.422 10.4627 128.961 8 125.925 8H115.771L111.858 1.73511Z" fill="white" stroke="#EAECEE"/>
</svg>
Actually, I used this path through polygon, but I couldn’t give it a border, so I guess I don’t know much.
2
Answers
You can use this code belo
you may have to create a paint for stroke and paint it twice as shown at the end of this code
Try this
using Flutter Shape Maker you can create CustomPainter code from any svg.