enterWrittenBarsOf function

Set<int> enterWrittenBarsOf(
  1. ChordChart grade,
  2. FollowEnter enter
)

Os compassos escritos (base 0) em que o enter entra: os de bars (que contam do 1), ou os da seção. A grade já foi conferida pelo leitor.

Implementation

Set<int> enterWrittenBarsOf(ChordChart grade, FollowEnter enter) {
  final bars = enter.bars;
  if (bars != null) {
    return {
      for (var w = bars.from - 1; w < bars.to && w < grade.bars.length; w++) w,
    };
  }
  final section = _sectionsOf(grade)
      .firstWhere((s) => s.label == enter.section, orElse: () => _noSection);
  return {for (var w = section.from; w < section.to; w++) w};
}