dash method

Path dash(
  1. Path root
)

Implementation

Path dash(Path root) {
  final dash = strokePoints;
  final metrics = root.computeMetrics(forceClosed: false);
  Path path = Path();

  for (PathMetric me in metrics) {
    double totalLength = me.length;
    int index = -1;

    for (double start = 0; start < totalLength;) {
      double to = start + dash[(++index) % dash.length];
      to = to > totalLength ? totalLength : to;
      bool isEven = index % 2 == 0;
      if (isEven) {
        path.addPath(
          me.extractPath(start, to, startWithMoveTo: true),
          Offset.zero,
        );
      }
      start = to;
    }
  }
  return path;
}