chartGradeOf function

ChordChart chartGradeOf(
  1. ChartSource source, {
  2. required String key,
  3. required String time,
})

A grade escrita de um exercício com grade, no tom key e na fórmula time. A leitura do curso já conferiu o texto, então aqui ele não tem como falhar.

Implementation

ChordChart chartGradeOf(
  ChartSource source, {
  required String key,
  required String time,
}) {
  final parsedKey = KeySpec.parse(key)!;
  final progression = source.progression;
  if (progression != null) {
    return ChordChart.fromProgression(
      progression,
      key: parsedKey,
      time: time,
      bars: source.bars,
    );
  }
  return ChordChart.parse(
    source.text!,
    key: parsedKey,
    time: time,
    error: (message, col) =>
        throw StateError('grade do exercício (coluna $col): $message'),
  )!;
}