diff --git a/lib/pages/set_sounds/constants/sounds.dart b/lib/pages/set_sounds/constants/sounds.dart index fe003ccc..39c0d896 100644 --- a/lib/pages/set_sounds/constants/sounds.dart +++ b/lib/pages/set_sounds/constants/sounds.dart @@ -13,16 +13,16 @@ const List soundsList = [ 'ding', 'ding-sequence', 'thunk', - '', + 'none', ]; const List countdownSounds = [ 'countdown-beep', 'short-rest-beep', - '', + 'none', ]; -var soundNames = { +final Map soundNames = { "long-bell": "Long bell", "countdown-beep": "Countdown beep", "ding-sequence": "Ding sequence", @@ -38,5 +38,5 @@ var soundNames = { "short-rest-beep": "Beep", "short-whistle": "Short whistle", "thunk": "Thunk", - "": "None" + "none": "None" }; diff --git a/lib/pages/set_sounds/set_sounds.dart b/lib/pages/set_sounds/set_sounds.dart index c745a8bf..e26f8d9a 100644 --- a/lib/pages/set_sounds/set_sounds.dart +++ b/lib/pages/set_sounds/set_sounds.dart @@ -82,7 +82,9 @@ class _SetSoundsState extends State { var soundIdMap = {}; for (final sound in allSounds) { - soundIdMap[sound] = loadSound(sound, pool); + if (sound != "none") { + soundIdMap[sound] = loadSound(sound, pool); + } } return Stack( @@ -116,10 +118,12 @@ class _SetSoundsState extends State { pool: pool, soundsList: soundsList, onFinished: (value) async { - if (value != '') { + if (!value.contains("none")) { await pool.play(await soundIdMap[value]); + widget.timer.soundSettings.workSound = value!; + } else { + widget.timer.soundSettings.workSound = ""; } - widget.timer.soundSettings.workSound = value!; }), SoundDropdown( dropdownKey: const Key("rest-sound"), @@ -129,10 +133,12 @@ class _SetSoundsState extends State { pool: pool, soundsList: soundsList, onFinished: (value) async { - if (value != '') { + if (!value.contains("none")) { await pool.play(await soundIdMap[value]); + widget.timer.soundSettings.restSound = value!; + } else { + widget.timer.soundSettings.restSound = ""; } - widget.timer.soundSettings.restSound = value!; }), SoundDropdown( dropdownKey: const Key("halfway-sound"), @@ -142,11 +148,13 @@ class _SetSoundsState extends State { pool: pool, soundsList: soundsList, onFinished: (value) async { - if (value != '') { + if (!value.contains("none")) { await pool.play(await soundIdMap[value]); + widget.timer.soundSettings.halfwaySound = + value!; + } else { + widget.timer.soundSettings.halfwaySound = ""; } - widget.timer.soundSettings.halfwaySound = - value!; }), SoundDropdown( dropdownKey: const Key("countdown-sound"), @@ -156,11 +164,14 @@ class _SetSoundsState extends State { pool: pool, soundsList: countdownSounds, onFinished: (value) async { - if (value != '') { + if (!value.contains("none")) { await pool.play(await soundIdMap[value]); + widget.timer.soundSettings.countdownSound = + value!; + } else { + widget.timer.soundSettings.countdownSound = + ""; } - widget.timer.soundSettings.countdownSound = - value!; }), SoundDropdown( dropdownKey: const Key("end-sound"), @@ -170,10 +181,12 @@ class _SetSoundsState extends State { pool: pool, soundsList: soundsList, onFinished: (value) async { - if (value != '') { + if (!value.contains("none")) { await pool.play(await soundIdMap[value]); + widget.timer.soundSettings.endSound = value!; + } else { + widget.timer.soundSettings.endSound = ""; } - widget.timer.soundSettings.endSound = value!; }), ], ))))),