Explorar o código

Allow replacing the ChewieController

Ben Hagen %!s(int64=6) %!d(string=hai) anos
pai
achega
e9d84e0901
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      lib/src/chewie_player.dart

+ 8 - 0
lib/src/chewie_player.dart

@@ -42,6 +42,14 @@ class ChewieState extends State<Chewie> {
     super.dispose();
   }
 
+  @override
+  void didUpdateWidget(Chewie oldWidget) {
+    if (oldWidget.controller != widget.controller) {
+      widget.controller.addListener(listener);
+    }
+    super.didUpdateWidget(oldWidget);
+  }
+
   void listener() async {
     if (widget.controller.isFullScreen && !_isFullScreen) {
       _isFullScreen = true;