durationRangeToDuration method

Duration durationRangeToDuration(
  1. List<DurationRange> buffered
)

Implementation

Duration durationRangeToDuration(List<DurationRange> buffered) {
  Duration totalDuration = Duration.zero;
  Duration prevEnd = buffered.first.start;
  for (final range in buffered) {
    // Check if ranges overlap
    final overlap = prevEnd.compareTo(range.start);

    // Adjust for overlap
    if (overlap <= 0) {
      // totalDuration += range.start;
    } else {
      totalDuration += range.end - prevEnd;
    }

    prevEnd = range.end;
  }
  return totalDuration;
}