Parcourir la source

Ensure that the widget is mounted before resetting the state

Vishnu Mohandas il y a 5 ans
Parent
commit
38b2c76892
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  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(() {});
+        }
       });
   }