当前位置: 首页> 汽车> 新车 > 广州广告公司排行榜_门户网站制作方法_东莞网站优化_2345网址导航官网下载

广州广告公司排行榜_门户网站制作方法_东莞网站优化_2345网址导航官网下载

时间:2025/7/12 14:14:30来源:https://blog.csdn.net/weixin_45625639/article/details/142386794 浏览次数: 0次
广州广告公司排行榜_门户网站制作方法_东莞网站优化_2345网址导航官网下载

说明

绘制一个圆环,进度为0时,显示“圆形”。

效果

在这里插入图片描述

源码

  • MyRingPainter
class MyRingPainter extends CustomPainter {final double progress;MyRingPainter({required this.progress});void paint(Canvas canvas, Size size) {double _strokeWidth = 12;double _halfWidth = size.width / 2;Offset _center = Offset(_halfWidth, _halfWidth);// 💡关键:找到真正的半径// double _radius = _halfWidth; // 绘制的圆环会超过size的范围double _radius = _halfWidth - _strokeWidth / 2; // 刚好卡在size范围内// 圆环背景色// 不填充圆内颜色Paint paint = Paint()..color = const Color(0xFFFF6258).withOpacity(0.12)..strokeWidth = _strokeWidth..style = PaintingStyle.stroke;canvas.drawCircle(_center, _radius, paint);//圆环进度Paint linePaint = Paint()..style = PaintingStyle.stroke..strokeWidth = _strokeWidth..strokeCap = StrokeCap.round // 线条末端样式为圆形..color = const Color(0xFFFF6258);// drawArc : 画弧形,但不连接圆心canvas.drawArc(Rect.fromCircle(radius: _radius, center: _center), -pi / 2,2 * pi * progress, false, linePaint);}bool shouldRepaint(MyRingPainter oldDelegate) {return oldDelegate.progress != progress;}
}
  • UI渲染
           Container(width: 244,height: 244,color: Colors.grey.withOpacity(0.15),child: CustomPaint(size: const Size(244, 244),painter: MyRingPainter(progress: 0.001),),)
关键字:广州广告公司排行榜_门户网站制作方法_东莞网站优化_2345网址导航官网下载

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: