From c96a2cb53acbe1675e38089d530a0195df728788 Mon Sep 17 00:00:00 2001 From: Syed Moiz Ali Date: Tue, 16 Jun 2026 13:14:11 +0530 Subject: [PATCH] fix: delay VideoPlayerController disposal to next frame to avoid crash on HQ switch --- lib/screens/video_player_screen.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 12f6ed2..daab502 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -321,8 +321,10 @@ class _VideoPlayerScreenState extends ConsumerState { _isPreviewMode = false; }); - oldController?.pause(); - oldController?.dispose(); + Future.microtask(() { + oldController?.pause(); + oldController?.dispose(); + }); } catch (e) { // HQ switch failed — keep playing preview (silent fallback) debugPrint('HQ switch failed, continuing preview: $e'); @@ -696,8 +698,8 @@ class _ControlsOverlay extends StatelessWidget { height: 4, onSeek: (fraction) { final target = Duration( - milliseconds: (fraction * duration.inMilliseconds) - .round(), + milliseconds: + (fraction * duration.inMilliseconds).round(), ); controller.seekTo(target); onInteraction();