0

How to create this corner-shaped card view in a flutter container.. How to create this corner shaped card view in a flutter container..?

Jahidul Islam
  • 11,435
  • 3
  • 17
  • 38

1 Answers1

3

You can archive this in several ways, using

Here is a demo of using CustomPaint, modify the value the way you like.

Result

enter image description here

Painter


class PriceTagPaint extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint()
      ..color = Colors.green
      ..strokeCap = StrokeCap.round
      ..style = PaintingStyle.fill;

    Path path = Path();

    path
      ..moveTo(0, size.height * .5)
      ..lineTo(size.width * .13, 0)
      ..lineTo(size.width, 0)
      ..lineTo(size.width, size.height)
      ..lineTo(size.width * .13, size.height)
      ..lineTo(0, size.height * .5)
      ..close();
    canvas.drawPath(path, paint);

    //* Circle
    canvas.drawCircle(
      Offset(size.width * .13, size.height * .5),
      size.height * .15,
      paint..color = Colors.white,
    );
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
}

And use

SizedBox(
      height: 100,
      width: 300,
      child: CustomPaint(
        painter: PriceTagPaint(),
        child: Center(
          child: Text(
            "Coolant",
            style: TextStyle(
              fontSize: 44,
            ),
          ),
        ),
      ),
    );

Check on dartpad or on gist

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56