Browse Source

Video download progress: Fix dispose behaviour (#1567)

Neeraj Gupta 1 year ago
parent
commit
6a8a33c14e
1 changed files with 5 additions and 1 deletions
  1. 5 1
      lib/ui/viewer/file/video_widget_new.dart

+ 5 - 1
lib/ui/viewer/file/video_widget_new.dart

@@ -90,10 +90,11 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>
 
   @override
   void dispose() {
+    removeCallBack(widget.file);
+    _progressNotifier.dispose();
     WidgetsBinding.instance.removeObserver(this);
     playingStreamSubscription.cancel();
     player.dispose();
-    _progressNotifier.dispose();
     super.dispose();
   }
 
@@ -159,6 +160,9 @@ class _VideoWidgetNewState extends State<VideoWidgetNew>
     getFileFromServer(
       widget.file,
       progressCallback: (count, total) {
+        if(!mounted) {
+          return;
+        }
         _progressNotifier.value = count / (widget.file.fileSize ?? total);
         if (_progressNotifier.value == 1) {
           if (mounted) {