How to create this corner-shaped card view in a flutter container..
Asked
Active
Viewed 1,023 times
0

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

LIJU DANIEL
- 88
- 8
-
please share some code – Jahidul Islam Sep 21 '21 at 14:33
-
@JahidulIslam, The below answer works for me. Cheers! – LIJU DANIEL Sep 21 '21 at 16:55
-
Please provide enough code so others can better understand or reproduce the problem. – Community Sep 29 '21 at 12:38
1 Answers
3
You can archive this in several ways, using
Here is a demo of using CustomPaint, modify the value the way you like.
Result
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,
),
),
),
),
);

Md. Yeasin Sheikh
- 54,221
- 7
- 29
- 56
-
@ Yeasin_Sheikh, Cheers! This made my day happy. I'm new in Flutter .. ); – LIJU DANIEL Sep 21 '21 at 16:53
-
Sure... @ Yeasin_Sheikh, Is it possible to apply corner radius & elevation in this view...? – LIJU DANIEL Sep 22 '21 at 10:50
-
We need to use brazier curve in that case a little complicated, for easy way try on [shapemaker](https://shapemaker.web.app/#/) – Md. Yeasin Sheikh Sep 22 '21 at 13:36