scoreSourceOf function

({Uint8List bytes, String fileName})? scoreSourceOf(
  1. Question? question,
  2. Uint8List? wrongScore,
  3. bool reviewing,
  4. QuestionRound round,
)

A partitura que a pergunta desenha, com o nome do arquivo: a da própria pergunta (com a nota errada, se houver uma em wrongScore), a da frase de compare (a de prompt, antes da revelação reviewing) ou a da rodada. null quando não há partitura.

Implementation

({Uint8List bytes, String fileName})? scoreSourceOf(
  Question? question,
  Uint8List? wrongScore,
  bool reviewing,
  QuestionRound round,
) {
  if (question?.scoreBytes case final bytes?) {
    return (
      bytes: wrongScore ?? bytes,
      fileName: question!.scoreFileName ?? 'round.musicxml',
    );
  }
  final compare = question?.compare;
  if (compare != null) {
    final bytes = reviewing
        ? compare.scoreBytes
        : compare.promptBytes ?? compare.scoreBytes;
    return (bytes: bytes, fileName: compare.fileName);
  }
  final bytes = round.scoreBytes;
  final fileName = round.fileName;
  if (bytes == null || fileName == null) return null;
  return (bytes: bytes, fileName: fileName);
}