Commit 03b5b1c0 authored by Chris Bracken's avatar Chris Bracken Committed by xster

Check video widget is mounted on call to setState (#18467)

When setState() calls occur asynchronously, it's possible that the
Futures on which they're waiting don't complete until the widget is
offscreen. To avoid this, we check the widget is mounted before calling
setState().
parent ab6df251
......@@ -151,6 +151,7 @@ class _VideoPlayPauseState extends State<VideoPlayPause> {
_VideoPlayPauseState() {
listener = () {
if (mounted)
setState(() {});
};
}
......@@ -374,6 +375,7 @@ class _VideoDemoState extends State<VideoDemo>
controller.play();
await connectedCompleter.future;
await controller.initialize();
if (mounted)
setState(() {});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment