Problem
In lib/screens/video_player_screen.dart (around line 318), the _navigateBack() method looks like this:
Future<void> _navigateBack() async {
// Save progress before leaving, then invalidate so lists refresh
if (_controller != null && _controller!.value.isInitialized) {
final position = _controller!.value.position.inSeconds;
if (position > 0) {
await _api.updateProgress(widget.videoId, position);
}
}
_controller?.pause();
if (mounted) {
Navigator.of(context).pop();
}
}
If the user hits the back button (or Android hardware back button), the UI is blocked waiting for the network request await _api.updateProgress(...) to finish. If the connection is slow or drops, the screen will hang on the video player before popping.
Suggested Fix
Remove the await from the _api.updateProgress call in _navigateBack(), allowing the network request to complete in the background (fire-and-forget), and immediately call _controller?.pause(); Navigator.pop(). Note that you also need to ensure ApiService isn't instantly disposed or cancelled before the background request completes.
Problem
In
lib/screens/video_player_screen.dart(around line 318), the_navigateBack()method looks like this:If the user hits the back button (or Android hardware back button), the UI is blocked waiting for the network request
await _api.updateProgress(...)to finish. If the connection is slow or drops, the screen will hang on the video player before popping.Suggested Fix
Remove the
awaitfrom the_api.updateProgresscall in_navigateBack(), allowing the network request to complete in the background (fire-and-forget), and immediately call_controller?.pause(); Navigator.pop(). Note that you also need to ensureApiServiceisn't instantly disposed or cancelled before the background request completes.