init method
Implementation
Future<void> init() async {
// Restore all user choices before loading audio (ENH-95). A missing key
// is the pre-ENH-95 state: keep the old 0.35 bgm / 1.0 sfx defaults.
final storage = StorageService.to;
muted.value = storage.getBool(StorageKeys.audioMuted, def: false);
bgmVolume.value = storage
.getDouble(StorageKeys.bgmVolume, def: _defaultBgmVolume)
.clamp(0.0, 1.0);
sfxVolume.value = storage
.getDouble(StorageKeys.sfxVolume, def: _defaultSfxVolume)
.clamp(0.0, 1.0);
try {
await _cache.loadAll([_bgmTrack]);
_ready = true;
} catch (_) {
// environment has no audio (e.g. some tests) → ignore, don't crash
_ready = false;
}
}