toggleShuffle method
void
toggleShuffle()
Implementation
void toggleShuffle() {
var currentSongId = audioTrack.id;
shuffle = !shuffle;
if (shuffle) {
playlist.shuffle();
var shuffledSongIndex =
playlist.indexWhere((song) => song.id == currentSongId);
var currentSong = playlist.removeAt(shuffledSongIndex);
playlist.insert(0, currentSong);
_index = 0;
} else {
playlist = [...sourcePlaylist];
_index = playlist.indexWhere((song) => song.id == currentSongId);
}
notifyListeners();
}