flutter 基础 —— CustomPaint 路径动画

路径动画

 

示例:

 flutter 基础 —— CustomPaint 路径动画

 

代码

var path = Path()
  ..moveTo(50, 50)
  ..lineTo(100, 100)
  ..lineTo(200, 90);
var rect1 = Rect.fromCircle(center: Offset(80, 450), radius: 60);
// 中间断开了
path.arcTo(rect1, 0, pi, true);
//由于前面断开了,所以总共有两段路径
ui.PathMetrics pathMetrics = path.computeMetrics();
if (_controller.value < 0.5) {
  var m = pathMetrics.first;
  Path extPath = m.extractPath(0, m.length* _controller.value*2);
  canvas.drawPath(
      extPath,
      Paint()
        ..strokeWidth = 5
        ..style = PaintingStyle.stroke
        ..color = Colors.red);
} else {
  var m = pathMetrics.last;
  Path extPath = m.extractPath(0, m.length* (_controller.value - 0.5) *2);
  canvas.drawPath(
      extPath,
      Paint()
        ..strokeWidth = 5
        ..style = PaintingStyle.stroke
        ..color = Colors.red);
}

  

2333

上一篇:CobaltStrike逆向学习系列(7):Controller 任务发布流程分析


下一篇:vivo 评论中台的流量及数据隔离实践