赞
踩
-----2022-11-28----
用Painter实现 代码虽然多了,但更直观些。
StackOverFlow原地址
class TrianglePainter extends CustomPainter { final Color strokeColor; final PaintingStyle paintingStyle; final double strokeWidth; TrianglePainter({this.strokeColor = Colors.black, this.strokeWidth = 3, this.paintingStyle = PaintingStyle.stroke}); @override void paint(Canvas canvas, Size size) { Paint paint = Paint() ..color = strokeColor ..strokeWidth = strokeWidth ..style = paintingStyle; canvas.drawPath(getTrianglePath(size.width, size.height), paint); } Path getTrianglePath(double x, double y) { return Path() ..moveTo(0, y) ..lineTo(x / 2, 0) ..lineTo(x, y) ..lineTo(0, y); } @
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。