diff --git a/lib/packages/miniplayer.dart b/lib/packages/miniplayer.dart index 4c471f8a..f7eba864 100644 --- a/lib/packages/miniplayer.dart +++ b/lib/packages/miniplayer.dart @@ -221,9 +221,9 @@ class NamidaMiniPlayer extends StatelessWidget { final currentIndex = Player.inst.currentIndex; final indminus = refine(currentIndex - 1); final indplus = refine(currentIndex + 1); - final prevTrack = Player.inst.currentQueue[indminus]; + final prevTrack = Player.inst.currentQueue.isEmpty ? null : Player.inst.currentQueue[indminus]; final currentTrack = Player.inst.nowPlayingTrack; - final nextTrack = Player.inst.currentQueue[indplus]; + final nextTrack = Player.inst.currentQueue.isEmpty ? null : Player.inst.currentQueue[indplus]; final currentDuration = currentTrack.duration; final currentDurationInMS = currentDuration * 1000; return Stack( @@ -1078,20 +1078,21 @@ class NamidaMiniPlayer extends StatelessWidget { builder: (context, child) { return Stack( children: [ - Opacity( - opacity: -sAnim.value.clamp(-1.0, 0.0), - child: Transform.translate( - offset: Offset(-sAnim.value * sMaxOffset / siParallax - sMaxOffset / siParallax, 0), - child: _TrackInfo( - trackPre: prevTrack.track, - p: bp, - cp: bcp, - bottomOffset: bottomOffset, - maxOffset: maxOffset, - screenSize: screenSize, + if (prevTrack != null) + Opacity( + opacity: -sAnim.value.clamp(-1.0, 0.0), + child: Transform.translate( + offset: Offset(-sAnim.value * sMaxOffset / siParallax - sMaxOffset / siParallax, 0), + child: _TrackInfo( + trackPre: prevTrack.track, + p: bp, + cp: bcp, + bottomOffset: bottomOffset, + maxOffset: maxOffset, + screenSize: screenSize, + ), ), ), - ), Opacity( opacity: 1 - sAnim.value.abs(), child: Transform.translate( @@ -1113,20 +1114,21 @@ class NamidaMiniPlayer extends StatelessWidget { ), ), ), - Opacity( - opacity: sAnim.value.clamp(0.0, 1.0), - child: Transform.translate( - offset: Offset(-sAnim.value * sMaxOffset / siParallax + sMaxOffset / siParallax, 0), - child: _TrackInfo( - trackPre: nextTrack.track, - p: bp, - cp: bcp, - bottomOffset: bottomOffset, - maxOffset: maxOffset, - screenSize: screenSize, + if (nextTrack != null) + Opacity( + opacity: sAnim.value.clamp(0.0, 1.0), + child: Transform.translate( + offset: Offset(-sAnim.value * sMaxOffset / siParallax + sMaxOffset / siParallax, 0), + child: _TrackInfo( + trackPre: nextTrack.track, + p: bp, + cp: bcp, + bottomOffset: bottomOffset, + maxOffset: maxOffset, + screenSize: screenSize, + ), ), - ), - ) + ) ], ); }, @@ -1143,24 +1145,25 @@ class NamidaMiniPlayer extends StatelessWidget { return Stack( children: [ - Opacity( - opacity: -sAnim.value.clamp(-1.0, 0.0), - child: Transform.translate( - offset: Offset(-sAnim.value * sMaxOffset / siParallax - sMaxOffset / siParallax, 0), - child: _RawImageContainer( - cp: bcp, - p: bp, - width: width, - screenSize: screenSize, - bottomOffset: bottomOffset, - maxOffset: maxOffset, - child: _TrackImage( - track: prevTrack.track, - cp: cp, + if (prevTrack != null) + Opacity( + opacity: -sAnim.value.clamp(-1.0, 0.0), + child: Transform.translate( + offset: Offset(-sAnim.value * sMaxOffset / siParallax - sMaxOffset / siParallax, 0), + child: _RawImageContainer( + cp: bcp, + p: bp, + width: width, + screenSize: screenSize, + bottomOffset: bottomOffset, + maxOffset: maxOffset, + child: _TrackImage( + track: prevTrack.track, + cp: cp, + ), ), ), ), - ), Opacity( opacity: 1 - sAnim.value.abs(), child: Transform.translate( @@ -1180,24 +1183,25 @@ class NamidaMiniPlayer extends StatelessWidget { ), ), ), - Opacity( - opacity: sAnim.value.clamp(0.0, 1.0), - child: Transform.translate( - offset: Offset(-sAnim.value * sMaxOffset / siParallax + sMaxOffset / siParallax, 0), - child: _RawImageContainer( - cp: bcp, - p: bp, - width: width, - screenSize: screenSize, - bottomOffset: bottomOffset, - maxOffset: maxOffset, - child: _TrackImage( - track: nextTrack.track, - cp: cp, + if (nextTrack != null) + Opacity( + opacity: sAnim.value.clamp(0.0, 1.0), + child: Transform.translate( + offset: Offset(-sAnim.value * sMaxOffset / siParallax + sMaxOffset / siParallax, 0), + child: _RawImageContainer( + cp: bcp, + p: bp, + width: width, + screenSize: screenSize, + bottomOffset: bottomOffset, + maxOffset: maxOffset, + child: _TrackImage( + track: nextTrack.track, + cp: cp, + ), ), ), ), - ), ], ); },