Page 1 of 1

So zeichnen Sie diese Form mit einem benutzerdefinierten Maler im Flattermodus

Posted: 19 Jan 2025, 19:28
by Guest
Ich möchte diese Pfeilform mit einem benutzerdefinierten Schmerzprogramm im Flatterstil zeichnen. Diese Form ist wie ein Cursor.
Das Wichtigste ist, dass die Ecken abgerundet sind..
Image

Hier ist mein aktueller Code:

Code: Select all

CustomPaint(
size: const Size(20, 61),
painter: TrianglePainter(color: appColor.fade(0.08)),
child: Padding(
padding: const EdgeInsets.only(left: 9, right: 16, top: 7, bottom: 7),
child: Text(
"28 book summaries a month",
style: const TextStyle(fontSize: 12.5, color: appColor, fontWeight: FontWeight.w500),
),
),
),

class TrianglePainter extends CustomPainter {
final Color color;

TrianglePainter({required this.color});

@override
void paint(Canvas canvas, Size size) {
final paint = Paint()
..color = color
..style = PaintingStyle.fill;

final path = Path();
final w = size.width;
final h = size.height;

path.moveTo(0, 0);
path.lineTo(w - (w * 0.2), 0);
path.lineTo(w, h / 2);
path.lineTo(w - (w * 0.2), h);
path.lineTo(0, h);
path.close();

canvas.drawPath(path, paint);
}

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