路径动画
示例:
代码
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