show method
Shows state — or nothing before the player has loaded a pack.
Showing the state already shown, with the same reducedMotion, does
nothing until the player loads another pack; then it shows it again.
Implementation
void show(SsUiState state, {bool reducedMotion = false}) {
final internal = player.internal;
final info = animeInfoOf(player);
if (internal == null || info == null) return;
if (identical(internal, _shownOn) &&
state == _state &&
reducedMotion == _reduced) {
return;
}
_shownOn = internal;
_state = state;
_reduced = reducedMotion;
final names = player.animationNames;
final base = _base != null && names.contains(_base)
? _base!
: (animation ?? player.currentAnimation ?? names.firstOrNull);
if (base == null) return;
_base = base;
final section = resolveUiSection(
state,
animation: base,
tableOf: (name) => labelTableOf(info, name),
clips: clips,
reducedMotion: reducedMotion,
onMissingClip: _reportMissingClip,
);
if (section == null) {
// The pack has no [base]; selecting it is what reports that.
player.setAnimation(base);
return;
}
if (!player.setAnimation(section.animation)) return;
player.setAnimationSection(section.startFrame, section.endFrame);
if (section.hold) {
player.stop();
} else {
player.loopCount = -1;
player.play();
}
}