From b1bed439ebf2be27be94dc9d220b194a310a211c Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Fri, 21 Nov 2025 03:52:48 +0100 Subject: [PATCH] fix: defer clearShuffle call to avoid setState during build --- lib/screens/video_player_screen.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 187ce3a0..0b372c31 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -105,7 +105,11 @@ class VideoPlayerScreenState extends State // If this item doesn't have a playQueueItemID, it's a standalone item // Clear any existing queue so next/previous work correctly for this content if (widget.metadata.playQueueItemID == null) { - playbackState.clearShuffle(); + // Defer clearing until after the first frame to avoid calling + // notifyListeners() during build + WidgetsBinding.instance.addPostFrameCallback((_) { + playbackState.clearShuffle(); + }); } else { playbackState.setCurrentItem(widget.metadata); }