dashPath function

Path? dashPath(
  1. Path? source, {
  2. required CircularIntervalList<double> dashedarray,
  3. DashOffset dashOffset = const DashOffset.absolute(0),
})

Implementation

Path? dashPath(Path? source,
    {required CircularIntervalList<double> dashedarray,
    DashOffset dashOffset = const DashOffset.absolute(0)}) {
  if (source == null) {
    return null;
  }
  final Path dest = Path();
  for (final PathMetric metric in source.computeMetrics()) {
    double distance = dashOffset._calculate(metric.length);
    bool draw = true;
    while (distance < metric.length) {
      final double len = dashedarray.next;
      if (draw) {
        dest.addPath(metric.extractPath(distance, distance + len), Offset.zero);
      }
      distance += len;
      draw = !draw;
    }
  }
  return dest;
}