prepare method
Monta a rodada do item. Devolve o motivo, em uma frase, se ela não se monta
(a música sumiu, a camada ou o trecho não existem nela); null se montou.
Implementation
Future<String?> prepare() async {
if (_round != null) return null;
final layer = item.layer;
final plan = await catalog.planOf(_hash, layer: layer);
final file = await catalog.itemFileOf(_hash, layer);
if (plan == null || file == null) {
return 'Não deu para abrir esta música agora.';
}
final outcome = musicRound(
plan: plan,
file: file,
item: item,
originalKeyLabel: layer == MusicItemLayer.original
? await _originalKeyOf(file)
: null,
);
switch (outcome) {
case MusicItemRoundRefused(:final reason):
return reason.text;
case MusicItemRoundReady(:final round):
_plan = plan;
_round = round;
_logRound(round);
return null;
}
}