@@ -22,7 +22,7 @@ abstract class GlobalParameters {
2222 ValueNotifier ('SplashScreen' );
2323
2424 static List <Playlist > playlists = List .generate (5 , (index) => Playlist ());
25- static List <Song > songs = < Song > [];
25+ static ValueNotifier < List <Song >> songs = ValueNotifier ( < Song > []) ;
2626
2727 static final SnappingSheetController snappingSheetController =
2828 SnappingSheetController ();
@@ -31,7 +31,7 @@ abstract class GlobalParameters {
3131 static AnimationController circleController;
3232 static AnimationController radiusController;
3333 static final ValueNotifier <bool > playNotifier = ValueNotifier (false );
34- static final ValueNotifier <Song > currentSong = ValueNotifier (songs[0 ]);
34+ static final ValueNotifier <Song > currentSong = ValueNotifier (songs.value.isNotEmpty ? songs.value [0 ] : Song () );
3535 static int songNumber = 0 ;
3636 static final ValueNotifier <double > songSeconds = ValueNotifier (0.0 );
3737 static final ValueNotifier <bool > shuffleMode = ValueNotifier (false );
@@ -52,16 +52,16 @@ abstract class GlobalParameters {
5252 }
5353
5454 static void playSongByID (int id) async {
55- songNumber = songs.indexWhere ((s) => s.id == id);
56- Song nextSong = songs[songNumber];
55+ songNumber = songs.value. indexWhere ((s) => s.id == id);
56+ Song nextSong = songs.value [songNumber];
5757 await nextSong.generateColors ();
5858 currentSong.value = nextSong;
5959 songSeconds.value = 0 ;
6060 }
6161
6262 static void playSongByIndex (int index) async {
6363 songNumber = index;
64- Song nextSong = songs[songNumber];
64+ Song nextSong = songs.value [songNumber];
6565 await nextSong.generateColors ();
6666 currentSong.value = nextSong;
6767 songSeconds.value = 0 ;
@@ -71,32 +71,32 @@ abstract class GlobalParameters {
7171 if (songNumber != 0 ) {
7272 songNumber-- ;
7373 } else {
74- songNumber = songs.length - 1 ;
74+ songNumber = songs.value. length - 1 ;
7575 }
7676 }
7777
7878 static void previousSong () async {
79- if (songs.length > 0 ) {
79+ if (songs.value. length > 0 ) {
8080 moveToPreviousIndex ();
81- Song song = songs[songNumber];
81+ Song song = songs.value [songNumber];
8282 await song.generateColors ();
8383 currentSong.value = song;
8484 songSeconds.value = 0 ;
8585 }
8686 }
8787
8888 static void moveToNextIndex () {
89- if (songNumber != songs.length - 1 ) {
89+ if (songNumber != songs.value. length - 1 ) {
9090 songNumber++ ;
9191 } else {
9292 songNumber = 0 ;
9393 }
9494 }
9595
9696 static void nextSong () async {
97- if (songs.length > 0 ) {
97+ if (songs.value. length > 0 ) {
9898 moveToNextIndex ();
99- Song song = songs[songNumber];
99+ Song song = songs.value [songNumber];
100100 await song.generateColors ();
101101 currentSong.value = song;
102102 songSeconds.value = 0 ;
0 commit comments