barLabelsOf function

Map<int, String> barLabelsOf(
  1. ChordChart grade
)

O nome de cada compasso escrito, no botão e na frase: o número (5), ou, com seções, a letra e o número dentro dela (B2). Um mapa de compasso (base 0).

Implementation

Map<int, String> barLabelsOf(ChordChart grade) {
  final sections = _sectionsOf(grade);
  final labelled = sections.where((s) => s.label != null).length;
  return {
    for (final section in sections)
      for (var w = section.from; w < section.to; w++)
        w: labelled >= 2
            ? '${section.label ?? ''}${w - section.from + 1}'
            : '${w + 1}',
  };
}