Browse Source

Ensure that the widget is mounted before resetting the state

Vishnu Mohandas 4 years ago
parent
commit
38b2c76892
1 changed files with 3 additions and 1 deletions
  1. 3 1
      lib/ui/video_widget.dart

+ 3 - 1
lib/ui/video_widget.dart

@@ -76,7 +76,9 @@ class _VideoWidgetState extends State<VideoWidget> {
   VideoPlayerController _setVideoPlayerController(String url) {
     return _videoPlayerController = VideoPlayerController.network(url)
       ..initialize().whenComplete(() {
-        setState(() {});
+        if (mounted) {
+          setState(() {});
+        }
       });
   }