Description
In lib/screens/video_player_screen.dart, the _switchToHq method synchronously disposes of the old VideoPlayerController right after calling setState():
setState(() {
_controller = hqController;
_isPreviewMode = false;
});
oldController?.pause();
oldController?.dispose();
Impact
This causes an assertion error (A VideoPlayerController was used after being disposed) because the widget tree hasn't fully unmounted the old VideoPlayer widget in the same frame, and listeners (ValueListenableBuilder) attached to it might still trigger updates.
Suggested Fix
Delay the disposal until the next frame using Future.microtask() or a timer, e.g., Future.delayed(const Duration(seconds: 1), () => oldController?.dispose());.
Description
In
lib/screens/video_player_screen.dart, the_switchToHqmethod synchronously disposes of the old VideoPlayerController right after callingsetState():Impact
This causes an assertion error (
A VideoPlayerController was used after being disposed) because the widget tree hasn't fully unmounted the oldVideoPlayerwidget in the same frame, and listeners (ValueListenableBuilder) attached to it might still trigger updates.Suggested Fix
Delay the disposal until the next frame using
Future.microtask()or a timer, e.g.,Future.delayed(const Duration(seconds: 1), () => oldController?.dispose());.