createDashedPath function
Implementation
Path createDashedPath(Path source, List<num> dashArray) {
final result = Path();
for (final metric in source.computeMetrics()) {
var dashIndex = 0;
var distance = 0.0;
var drawDash = true;
while (distance < metric.length) {
final currentDash = dashArray.elementAt(dashIndex);
if (drawDash) {
result.addPath(
metric.extractPath(distance, distance + currentDash),
Offset.zero,
);
}
distance += currentDash;
drawDash = !drawDash;
dashIndex++;
if (dashIndex >= dashArray.length) {
dashIndex = 0;
}
}
}
return result;
}